diff --git a/README.md b/README.md index 06e938483..ede02510d 100644 --- a/README.md +++ b/README.md @@ -1,271 +1,99 @@ -[![npm version](https://badge.fury.io/js/typescript-plus.svg)](https://www.npmjs.com/package/typescript-plus) - -[中文版](http://www.idom.me/articles/849.html) - -# typescript-plus - - - -TypeScript is a language for application-scale JavaScript, For more information, please visit : [TypeScript](https://github.com/Microsoft/TypeScript). - -The typescript-plus compiler provides extra features to the original typescript compiler, such as accessors optimization, class reflection, conditional compilation and the most useful one: automatically reordering the source files by analyzing their dependencies in code. This compiler is integrated into the [Egret Engine](https://github.com/egret-labs/egret-core) and has been heavily used by it. - -This project will try to stay up to date with the new release of the original TypeScript project. - -Current TypeScript Version: 3.1.3 - - -## Installing - -First, make sure you have installed the latest version of [node.js](http://nodejs.org/) -(You may need to restart your computer after this step). - -For use as a command line app: - -``` -npm install -g typescript-plus -``` - -For programmatic use: - -``` -npm install typescript-plus -``` - -## Usage - -``` -tsc-plus [input files] [options] -``` - -To learn how to use the original typescript compiler, please visit the following links: - -* [Quick tutorial](http://www.typescriptlang.org/Tutorial) -* [Programming handbook](http://www.typescriptlang.org/Handbook) -* [Language specification](https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md) -* [Homepage](http://www.typescriptlang.org/) - -## Extra Options - -| Option | Type | Default| Description | -|:-------------------- |:-------:|:------:| :------------------------------------------------- | -| accessorOptimization | boolean | false | If an accessor contains only one call to another method, use that method to define the accessor directly.| -| emitReflection | boolean | false | Emit the reflection data of the class. | -| reorderFiles | boolean | false | Automatically reordering the source files by dependencies.| -| defines | Object | | Replace the global variables with the constants defined in the "defines" object. | - - - -Example tsconfig.json file: - -``` -{ - "compilerOptions": { - "module": "commonjs", - "noImplicitAny": true, - "removeComments": true, - "preserveConstEnums": true, - "sourceMap": true, - "accessorOptimization": true, - "emitReflection": true, - "reorderFiles": true - "defines": { - "DEBUG": false, - "RELEASE": true - } - - }, - "files": [ - "core.ts", - "sys.ts" - ] -} - -``` - -## Accessor Optimization - -Pass `--accessorOptimization` to the command-line tool or add `"accessorOptimization": true` to the `compilerOptions` in tsconfig.json file to enable this feature. - -As we know, we can't override the get / set accessors of super class in TypeScript. To solve the problem, we usually forward the call to the set accessor to another method: - -TypeScript: - -``` -class Student { - - public _name:string; - - protected setName(value:string):void { - this._name = value; - } - - public get name():string { - return this._name; - } - - public set name(value:string) { - this.setName(value); - } -} -``` -It does solve the problem, but also brings a performance issue, that two functions have to be called each time we call a set accessor. With the `--accessorOptimization` switch on, if the accessor contains only one call to another method, the compiler uses that method to define accessor directly. - -Javascript: - -``` -var Student = (function () { - function Student() { - } - Student.prototype.setName = function (value) { - this._name = value; - }; - Object.defineProperty(Student.prototype, "name", { - get: function () { - return this._name; - }, - set: Student.prototype.setName, - enumerable: true, - configurable: true - }); - return Student; -}()); -``` - -If you define the `setName()` method after the set accessor, the final result looks like this: - -``` -var Student = (function () { - function Student() { - } - Object.defineProperty(Student.prototype, "name", { - get: function () { - return this._name; - }, - set: setName, - enumerable: true, - configurable: true - }); - Student.prototype.setName = setName; - function setName(value) { - this._name = value; - }; - return Student; -}()); -``` -Either way, it works. - -## Class Reflection - -Pass `--emitReflection` to the command-line tool or add `"emitReflection": true` to the `compilerOptions` in tsconfig.json file to enable this feature. - -TypeScript: - -``` -namespace ts { - export interface IPerson { - name:string; - } - - export class Student implements IPerson { - public name:string = ""; - } -} -``` -JavaScript: - -``` -var ts; -(function (ts) { - var Student = (function () { - function Student() { - this.name = ""; - } - return Student; - }()); - ts.Student = Student; - __reflect(Student.prototype, "ts.Student", ["ts.IPerson"]); -})(ts || (ts = {})); - -``` -The `__reflect` helper function is just like the `__extends` function, it is emitted only once in one file. - -Then you can use the helper funtions in [reflection.ts](tools/reflection.ts) to get the qualified class name of an instance: - -``` -let student = new ts.Student(); -ts.getQualifiedClassName(student); // "ts.Student" -``` -or do some type checking: - -``` -ts.is(student, "ts.Student"); // true -ts.is(student, "ts.IPersion"); // true -``` - -## SourceFiles Reordering - -Pass `--reorderFiles` to the command-line tool or add `"reorderFiles": true` to the `compilerOptions` in tsconfig.json file to enable this feature. - -Normally when you pass the `--outFile` option, the compiler will concatenate and emit output to a single file. But the order of concatenation is determined by the list of files passed to the compiler on the command line (or in the tsconfig.json file) along with triple-slash references and imports. That forces you to sort the input files in the correct order manually. It is ok with only a few source files, but it becomes a disaster when you have countless source files. - -With the `reorderFiles` switch on, the compiler will automatically reorder the source files by analyzing their dependencies in code. Then you can get the correct concatenation order in the generated file without doing any extra effort. I have tested this feature in many real-world projects, it works very well. If it does not work in your project, please feel free to open an issue and send me the test case. - -## Conditional Compilation - -The `defines` option is only allowed in tsconfig.json, and not through command-line switches. - -You can use the `defines` option to declare global variables that the compiler will assume to be constants (unless defined in scope). Then all the defined global variables will be replaced with the corresponding constants. For example: - -tsconfig.json: - -``` -{ - "compilerOptions": { - "defines": { - "DEBUG": false, - "LANGUAGE": "en_US" - } - } -} - -``` -TypeScript: - -``` -declare var DEBUG:boolean; -declare var LANGUAGE:string; - -if (DEBUG) { - console.log("DEBUG is true"); -} - -console.log("The language is : " + LANGUAGE); - -function someFunction():void { - let DEBUG = true; - if (DEBUG) { - console.log("DEBUG is true"); - } -} - -``` -JavaScript: - -``` -if (false) { - console.log("DEBUG is true"); -} - -console.log("The language is : " + "en_US"); - -function someFunction() { - var DEBUG = true; - if (DEBUG) { - console.log("DEBUG is true"); - } -} -``` -As you can see, the second `if(DEBUG)` in `someFunction` is not replaced because it is defined in scope. - -Note that the compiler does not drop the unreachable code because it is can be easily done by other tools like [UglifyJS](http://lisperator.net/uglifyjs/) or [Google Closure Compiler](https://developers.google.com/closure/compiler/). +[![Build Status](https://travis-ci.org/Microsoft/TypeScript.svg?branch=master)](https://travis-ci.org/Microsoft/TypeScript) +[![VSTS Build Status](https://typescript.visualstudio.com/_apis/public/build/definitions/cf7ac146-d525-443c-b23c-0d58337efebc/4/badge)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=4&view=logs) +[![npm version](https://badge.fury.io/js/typescript.svg)](https://www.npmjs.com/package/typescript) +[![Downloads](https://img.shields.io/npm/dm/typescript.svg)](https://www.npmjs.com/package/typescript) + +# TypeScript + +[![Join the chat at https://gitter.im/Microsoft/TypeScript](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +[TypeScript](https://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types to JavaScript that support tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](https://www.typescriptlang.org/play/), and stay up to date via [our blog](https://blogs.msdn.microsoft.com/typescript) and [Twitter account](https://twitter.com/typescriptlang). + +## Installing + +For the latest stable version: + +```bash +npm install -g typescript +``` + +For our nightly builds: + +```bash +npm install -g typescript@next +``` + +## Contribute + +There are many ways to [contribute](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md) to TypeScript. +* [Submit bugs](https://github.com/Microsoft/TypeScript/issues) and help us verify fixes as they are checked in. +* Review the [source code changes](https://github.com/Microsoft/TypeScript/pulls). +* Engage with other TypeScript users and developers on [StackOverflow](https://stackoverflow.com/questions/tagged/typescript). +* Join the [#typescript](https://twitter.com/#!/search/realtime/%23typescript) discussion on Twitter. +* [Contribute bug fixes](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md). +* Read the language specification ([docx](https://github.com/Microsoft/TypeScript/blob/master/doc/TypeScript%20Language%20Specification.docx?raw=true), + [pdf](https://github.com/Microsoft/TypeScript/blob/master/doc/TypeScript%20Language%20Specification.pdf?raw=true), [md](https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md)). + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see +the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) +with any additional questions or comments. + +## Documentation + +* [Quick tutorial](https://www.typescriptlang.org/docs/tutorial.html) +* [Programming handbook](https://www.typescriptlang.org/docs/handbook/basic-types.html) +* [Language specification](https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md) +* [Homepage](https://www.typescriptlang.org/) + +## Building + +In order to build the TypeScript compiler, ensure that you have [Git](https://git-scm.com/downloads) and [Node.js](https://nodejs.org/) installed. + +Clone a copy of the repo: + +```bash +git clone https://github.com/Microsoft/TypeScript.git +``` + +Change to the TypeScript directory: + +```bash +cd TypeScript +``` + +Install Jake tools and dev dependencies: + +```bash +npm install -g jake +npm install +``` + +Use one of the following to build and test: + +``` +jake local # Build the compiler into built/local +jake clean # Delete the built compiler +jake LKG # Replace the last known good with the built one. + # Bootstrapping step to be executed when the built compiler reaches a stable state. +jake tests # Build the test infrastructure using the built compiler. +jake runtests # Run tests using the built compiler and test infrastructure. + # You can override the host or specify a test for this command. + # Use host= or tests=. +jake runtests-browser # Runs the tests using the built run.js file. Syntax is jake runtests. Optional + parameters 'host=', 'tests=[regex], reporter=[list|spec|json|]'. +jake baseline-accept # This replaces the baseline test results with the results obtained from jake runtests. +jake lint # Runs tslint on the TypeScript source. +jake help # List the above commands. +``` + + +## Usage + +```bash +node built/local/tsc.js hello.ts +``` + + +## Roadmap + +For details on our planned features and future direction please refer to our [roadmap](https://github.com/Microsoft/TypeScript/wiki/Roadmap). diff --git a/lib/lib.esnext.promise.d.ts b/lib/lib.esnext.promise.d.ts deleted file mode 100644 index d73b4d456..000000000 --- a/lib/lib.esnext.promise.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -/*! ***************************************************************************** -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. -***************************************************************************** */ - - - -/// - - -/** - * Represents the completion of an asynchronous operation - */ -interface Promise { - /** - * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The - * resolved value cannot be modified from the callback. - * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected). - * @returns A Promise for the completion of the callback. - */ - finally(onfinally?: (() => void) | undefined | null): Promise -} diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index 9e0f56abe..180be261b 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -61,7 +61,8 @@ declare namespace ts.server.protocol { GetApplicableRefactors = "getApplicableRefactors", GetEditsForRefactor = "getEditsForRefactor", OrganizeImports = "organizeImports", - GetEditsForFileRename = "getEditsForFileRename" + GetEditsForFileRename = "getEditsForFileRename", + ConfigurePlugin = "configurePlugin" } /** * A TypeScript Server message @@ -1006,6 +1007,14 @@ declare namespace ts.server.protocol { */ interface ConfigureResponse extends Response { } + interface ConfigurePluginRequestArguments { + pluginName: string; + configuration: any; + } + interface ConfigurePluginRequest extends Request { + command: CommandTypes.ConfigurePlugin; + arguments: ConfigurePluginRequestArguments; + } /** * Information found in an "open" request. */ diff --git a/lib/tsc.js b/lib/tsc.js index 06be1d435..f39e9517a 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -60,8 +60,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook var ts; (function (ts) { ts.versionMajorMinor = "3.1"; - ts.version = ts.versionMajorMinor + ".3"; - ts.version_plus = "3.1.5"; + ts.version = ts.versionMajorMinor + ".5"; })(ts || (ts = {})); (function (ts) { ts.emptyArray = []; @@ -4137,6 +4136,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var _a; function tokenIsIdentifierOrKeyword(token) { return token >= 71; } @@ -4145,136 +4145,85 @@ var ts; return token === 29 || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; - var textToToken = ts.createMapFromTemplate({ - "abstract": 117, - "any": 119, - "as": 118, - "boolean": 122, - "break": 72, - "case": 73, - "catch": 74, - "class": 75, - "continue": 77, - "const": 76, - "constructor": 123, - "debugger": 78, - "declare": 124, - "default": 79, - "delete": 80, - "do": 81, - "else": 82, - "enum": 83, - "export": 84, - "extends": 85, - "false": 86, - "finally": 87, - "for": 88, - "from": 143, - "function": 89, - "get": 125, - "if": 90, - "implements": 108, - "import": 91, - "in": 92, - "infer": 126, - "instanceof": 93, - "interface": 109, - "is": 127, - "keyof": 128, - "let": 110, - "module": 129, - "namespace": 130, - "never": 131, - "new": 94, - "null": 95, - "number": 134, - "object": 135, - "package": 111, - "private": 112, - "protected": 113, - "public": 114, - "readonly": 132, - "require": 133, - "global": 144, - "return": 96, - "set": 136, - "static": 115, - "string": 137, - "super": 97, - "switch": 98, - "symbol": 138, - "this": 99, - "throw": 100, - "true": 101, - "try": 102, - "type": 139, - "typeof": 103, - "undefined": 140, - "unique": 141, - "unknown": 142, - "var": 104, - "void": 105, - "while": 106, - "with": 107, - "yield": 116, - "async": 120, - "await": 121, - "of": 145, - "{": 17, - "}": 18, - "(": 19, - ")": 20, - "[": 21, - "]": 22, - ".": 23, - "...": 24, - ";": 25, - ",": 26, - "<": 27, - ">": 29, - "<=": 30, - ">=": 31, - "==": 32, - "!=": 33, - "===": 34, - "!==": 35, - "=>": 36, - "+": 37, - "-": 38, - "**": 40, - "*": 39, - "/": 41, - "%": 42, - "++": 43, - "--": 44, - "<<": 45, - ">": 46, - ">>>": 47, - "&": 48, - "|": 49, - "^": 50, - "!": 51, - "~": 52, - "&&": 53, - "||": 54, - "?": 55, - ":": 56, - "=": 58, - "+=": 59, - "-=": 60, - "*=": 61, - "**=": 62, - "/=": 63, - "%=": 64, - "<<=": 65, - ">>=": 66, - ">>>=": 67, - "&=": 68, - "|=": 69, - "^=": 70, - "@": 57, - }); + var textToKeywordObj = (_a = { + abstract: 117, + any: 119, + as: 118, + boolean: 122, + break: 72, + case: 73, + catch: 74, + class: 75, + continue: 77, + const: 76 + }, + _a["" + "constructor"] = 123, + _a.debugger = 78, + _a.declare = 124, + _a.default = 79, + _a.delete = 80, + _a.do = 81, + _a.else = 82, + _a.enum = 83, + _a.export = 84, + _a.extends = 85, + _a.false = 86, + _a.finally = 87, + _a.for = 88, + _a.from = 143, + _a.function = 89, + _a.get = 125, + _a.if = 90, + _a.implements = 108, + _a.import = 91, + _a.in = 92, + _a.infer = 126, + _a.instanceof = 93, + _a.interface = 109, + _a.is = 127, + _a.keyof = 128, + _a.let = 110, + _a.module = 129, + _a.namespace = 130, + _a.never = 131, + _a.new = 94, + _a.null = 95, + _a.number = 134, + _a.object = 135, + _a.package = 111, + _a.private = 112, + _a.protected = 113, + _a.public = 114, + _a.readonly = 132, + _a.require = 133, + _a.global = 144, + _a.return = 96, + _a.set = 136, + _a.static = 115, + _a.string = 137, + _a.super = 97, + _a.switch = 98, + _a.symbol = 138, + _a.this = 99, + _a.throw = 100, + _a.true = 101, + _a.try = 102, + _a.type = 139, + _a.typeof = 103, + _a.undefined = 140, + _a.unique = 141, + _a.unknown = 142, + _a.var = 104, + _a.void = 105, + _a.while = 106, + _a.with = 107, + _a.yield = 116, + _a.async = 120, + _a.await = 121, + _a.of = 145, + _a); + var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); + var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 17, "}": 18, "(": 19, ")": 20, "[": 21, "]": 22, ".": 23, "...": 24, ";": 25, ",": 26, "<": 27, ">": 29, "<=": 30, ">=": 31, "==": 32, "!=": 33, "===": 34, "!==": 35, "=>": 36, "+": 37, "-": 38, "**": 40, "*": 39, "/": 41, "%": 42, "++": 43, "--": 44, "<<": 45, ">": 46, ">>>": 47, "&": 48, "|": 49, "^": 50, "!": 51, "~": 52, "&&": 53, "||": 54, "?": 55, ":": 56, "=": 58, "+=": 59, "-=": 60, "*=": 61, "**=": 62, "/=": 63, "%=": 64, "<<=": 65, ">>=": 66, ">>>=": 67, "&=": 68, "|=": 69, "^=": 70, "@": 57 })); 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,]; @@ -5133,9 +5082,9 @@ var ts; if (len >= 2 && len <= 11) { var ch = tokenValue.charCodeAt(0); if (ch >= 97 && ch <= 122) { - token = textToToken.get(tokenValue); - if (token !== undefined) { - return token; + var keyword = textToKeyword.get(tokenValue); + if (keyword !== undefined) { + return token = keyword; } } } @@ -5779,7 +5728,7 @@ var ts; pos++; } tokenValue = text.substring(tokenPos, pos); - return token = 71; + return token = getIdentifierToken(); } else { return token = 0; @@ -17203,7 +17152,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(281, scanner.getTokenPos()); + var result = createNode(281); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17); result.type = doInsideOfContext(2097152, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -17370,7 +17319,7 @@ var ts; nextJSDocToken(); } } - function skipWhitespaceOrAsterisk(next) { + function skipWhitespaceOrAsterisk() { if (token() === 5 || token() === 4) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return; @@ -17384,7 +17333,7 @@ var ts; else if (token() === 39) { precedingLineBreak = false; } - next(); + nextJSDocToken(); } } function parseTag(indent) { @@ -17392,8 +17341,8 @@ var ts; var atToken = createNode(57, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); - var tagName = parseJSDocIdentifierName(undefined, nextToken); - skipWhitespaceOrAsterisk(nextToken); + var tagName = parseJSDocIdentifierName(undefined); + skipWhitespaceOrAsterisk(); var tag; switch (tagName.escapedText) { case "augments": @@ -17523,7 +17472,7 @@ var ts; tagsEnd = tag.end; } function tryParseTypeExpression() { - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); return token() === 17 ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { @@ -17554,7 +17503,7 @@ var ts; function parseParameterOrPropertyTag(atToken, tagName, target, indent) { var typeExpression = tryParseTypeExpression(); var isNameFirst = !typeExpression; - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed; skipWhitespace(); if (isNameFirst) { @@ -17673,7 +17622,7 @@ var ts; } function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); var typedefTag = createNode(302, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; @@ -17901,8 +17850,7 @@ var ts; } return entity; } - function parseJSDocIdentifierName(message, next) { - if (next === void 0) { next = nextJSDocToken; } + function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { return createMissingNode(71, !message, message || ts.Diagnostics.Identifier_expected); } @@ -17911,7 +17859,7 @@ var ts; var result = createNode(71, pos); result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); finishNode(result, end); - next(); + nextJSDocToken(); return result; } } @@ -19157,27 +19105,6 @@ var ts; type: "object" }, description: ts.Diagnostics.List_of_language_service_plugins - }, - { - name: "accessorOptimization", - type: "boolean" - }, - { - name: "defines", - type: "object", - isTSConfigOnly: true - }, - { - name: "emitReflection", - type: "boolean" - }, - { - name: "noEmitJs", - type: "boolean" - }, - { - name: "reorderFiles", - type: "boolean" } ]); ts.semanticDiagnosticsOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsSemanticDiagnostics; }); @@ -19466,8 +19393,7 @@ var ts; return diagnostic.messageText; } function printVersion() { - ts.sys.write("Version : " + ts.version_plus + ts.sys.newLine); - ts.sys.write("typescript-version : " + ts.version + ts.sys.newLine); + ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + ts.sys.newLine); } ts.printVersion = printVersion; function printHelp(optionsList, syntaxPrefix) { @@ -46856,7 +46782,8 @@ var ts; return true; } var target = getSymbolLinks(symbol).target; - if (target && ts.getModifierFlags(node) & 1 && target.flags & 67220415) { + if (target && ts.getModifierFlags(node) & 1 && + target.flags & 67220415 && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { return true; } } @@ -57213,7 +57140,6 @@ var ts; var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); - var typeChecker = context.getEmitHost().getTypeChecker(); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; @@ -57837,13 +57763,7 @@ var ts; statements.push(transformSemicolonClassElementToStatement(member)); break; case 154: - var method = member; - if (method.isJumpTarget || (method.original && method.original.isJumpTarget)) { - transformJumpTarget(statements, getClassMemberPrefix(node, member), member); - } - else { - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); - } + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; case 156: case 157: @@ -57860,25 +57780,6 @@ var ts; } } } - function transformJumpTarget(statements, receiver, member) { - var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name); - statements.push(ts.createStatement(ts.createAssignment(memberName, member.name))); - var sourceMapRange = ts.getSourceMapRange(member); - var memberFunction = transformMethodToFunctionDeclaration(member, member, member.name); - ts.setEmitFlags(memberFunction, 1536); - ts.setSourceMapRange(memberFunction, sourceMapRange); - statements.push(memberFunction); - } - function transformMethodToFunctionDeclaration(node, location, name) { - var savedConvertedLoopState = convertedLoopState; - convertedLoopState = undefined; - var ancestorFacts = enterSubtree(16286, 65); - var parameters = ts.visitParameterList(node.parameters, visitor, context); - var body = transformFunctionBody(node); - exitSubtree(ancestorFacts, 49152, 0); - convertedLoopState = savedConvertedLoopState; - return ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name, undefined, parameters, undefined, body), location), node); - } function transformSemicolonClassElementToStatement(member) { return ts.setTextRange(ts.createEmptyStatement(), member); } @@ -57914,14 +57815,18 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterExpression = createAccessorExpression(getAccessor, firstAccessor, receiver, container); - var getter = ts.createPropertyAssignment("get", getterExpression); + var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined, container); + ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); + ts.setEmitFlags(getterFunction, 512); + var getter = ts.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); } if (setAccessor) { - var setterExpression = createAccessorExpression(setAccessor, firstAccessor, receiver, container); - var setter = ts.createPropertyAssignment("set", setterExpression); + var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined, container); + ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); + ts.setEmitFlags(setterFunction, 512); + var setter = ts.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } @@ -57937,72 +57842,6 @@ var ts; exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return call; } - function createAccessorExpression(accessor, firstAccessor, receiver, container) { - var expression; - var method = compilerOptions.accessorOptimization ? getJumpTargetOfAccessor(accessor) : null; - if (method) { - var methodName = ts.getMutableClone(method.name); - ts.setEmitFlags(methodName, 1536 | 32); - ts.setSourceMapRange(methodName, method.name); - if (firstAccessor.pos > method.pos) { - var target = ts.getMutableClone(receiver); - ts.setEmitFlags(target, 1536 | 32); - ts.setSourceMapRange(target, firstAccessor.name); - expression = ts.createPropertyAccess(target, methodName); - } - else { - expression = methodName; - method.isJumpTarget = true; - } - } - else { - expression = transformFunctionLikeToExpression(accessor, undefined, undefined, container); - } - ts.setSourceMapRange(expression, ts.getSourceMapRange(accessor)); - ts.setEmitFlags(expression, 512); - return expression; - } - function getJumpTargetOfAccessor(accessor) { - if (accessor.body.statements.length != 1) { - return undefined; - } - var statement = accessor.body.statements[0]; - if (statement.kind !== 219 && - statement.kind !== 228) { - return undefined; - } - var expression = statement.expression; - if (expression.kind !== 189) { - return undefined; - } - var callExpression = expression; - if (accessor.kind === 157) { - if (callExpression.arguments.length != 1) { - return undefined; - } - var argument = callExpression.arguments[0]; - if (argument.kind !== 71) { - return undefined; - } - } - else { - if (callExpression.arguments.length != 0) { - return undefined; - } - } - if (callExpression.expression.kind !== 187) { - return undefined; - } - var propertyExpression = callExpression.expression; - if (propertyExpression.expression.kind !== 99) { - return undefined; - } - var symbol = typeChecker.getSymbolAtLocation(propertyExpression.name); - if (!symbol) { - return undefined; - } - return ts.getDeclarationOfKind(symbol, 154); - } function visitArrowFunction(node) { if (node.transformFlags & 16384) { enableSubstitutionsForCapturedThis(); @@ -64201,9 +64040,6 @@ var ts; var moduleKind = ts.getEmitModuleKind(compilerOptions); var transformers = []; ts.addRange(transformers, customTransformers && customTransformers.before); - if (compilerOptions.defines || compilerOptions.emitReflection) { - transformers.push(ts.transformTypeScriptPlus); - } transformers.push(ts.transformTypeScript); if (jsx === 2) { transformers.push(ts.transformJsx); @@ -64430,910 +64266,6 @@ var ts; ts.transformNodes = transformNodes; })(ts || (ts = {})); var ts; -(function (ts) { - function transformTypeScriptPlus(context) { - var compilerOptions = context.getCompilerOptions(); - var compilerDefines = getCompilerDefines(compilerOptions.defines); - var typeChecker = compilerOptions.emitReflection || compilerDefines ? context.getEmitHost().getTypeChecker() : null; - var previousOnSubstituteNode = context.onSubstituteNode; - if (compilerDefines) { - context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(71); - } - return ts.chainBundle(transformSourceFile); - function transformSourceFile(node) { - if (!compilerOptions.emitReflection) { - return node; - } - var visited = ts.updateSourceFileNode(node, ts.visitNodes(node.statements, visitStatement, ts.isStatement)); - ts.addEmitHelpers(visited, context.readEmitHelpers()); - return visited; - } - function visitStatement(node) { - if (ts.hasModifier(node, 2)) { - return node; - } - if (node.kind === 238) { - return visitClassDeclaration(node); - } - if (node.kind === 242) { - return visitModule(node); - } - return node; - } - function visitModule(node) { - if (node.body.kind === 242) { - return updateModuleDeclaration(node, visitModule(node.body)); - } - if (node.body.kind === 243) { - var body = updateModuleBlock(node.body, ts.visitNodes(node.body.statements, visitStatement, ts.isStatement)); - return updateModuleDeclaration(node, body); - } - return node; - } - function updateModuleDeclaration(node, body) { - if (node.body !== body) { - var updated = ts.getMutableClone(node); - updated.body = body; - return ts.updateNode(updated, node); - } - return node; - } - function updateModuleBlock(node, statements) { - if (node.statements !== statements) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements); - return ts.updateNode(updated, node); - } - return node; - } - function visitClassDeclaration(node) { - var classStatement = ts.getMutableClone(node); - var statements = [classStatement]; - var interfaceMap = {}; - getImplementedInterfaces(node, interfaceMap); - var allInterfaces = Object.keys(interfaceMap); - var interfaces; - var superTypes = getSuperClassTypes(node); - if (superTypes) { - interfaces = []; - for (var _i = 0, allInterfaces_1 = allInterfaces; _i < allInterfaces_1.length; _i++) { - var type = allInterfaces_1[_i]; - if (superTypes.indexOf(type) === -1) { - interfaces.push(type); - } - } - } - else { - interfaces = allInterfaces; - } - node.typeNames = interfaces; - var fullClassName = typeChecker.getFullyQualifiedName(node.symbol); - var expression = createReflectHelper(context, node.name, fullClassName, interfaces); - ts.setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); - var statement = ts.createStatement(expression); - ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); - statements.push(statement); - return statements; - } - function getImplementedInterfaces(node, result) { - var superInterfaces = undefined; - if (node.kind === 238) { - superInterfaces = ts.getClassImplementsHeritageClauseElements(node); - } - else { - superInterfaces = ts.getInterfaceBaseTypeNodes(node); - } - if (superInterfaces) { - superInterfaces.forEach(function (superInterface) { - var type = typeChecker.getTypeAtLocation(superInterface); - if (type && type.symbol && type.symbol.flags & 64) { - var symbol = type.symbol; - var fullName = typeChecker.getFullyQualifiedName(symbol); - result[fullName] = true; - var declaration = ts.getDeclarationOfKind(symbol, 239); - if (declaration) { - getImplementedInterfaces(declaration, result); - } - } - }); - } - } - function getSuperClassTypes(node) { - var superClass = ts.getClassExtendsHeritageElement(node); - if (!superClass) { - return undefined; - } - var type = typeChecker.getTypeAtLocation(superClass); - if (!type || !type.symbol) { - return undefined; - } - var declaration = ts.getDeclarationOfKind(type.symbol, 238); - return declaration ? declaration.typeNames : undefined; - } - function getCompilerDefines(defines) { - if (!defines) { - return null; - } - var compilerDefines = {}; - var keys = Object.keys(defines); - for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { - var key = keys_1[_i]; - var value = defines[key]; - var type = typeof value; - switch (type) { - case "boolean": - case "number": - compilerDefines[key] = value.toString(); - break; - case "string": - compilerDefines[key] = "\"" + value + "\""; - break; - } - } - if (Object.keys(compilerDefines).length == 0) { - return null; - } - return compilerDefines; - } - function isDefinedConstant(node) { - var nodeText = ts.getTextOfIdentifierOrLiteral(node); - if (compilerDefines[nodeText] === undefined) { - return false; - } - if (!node.parent) { - return false; - } - if (node.parent.kind === 235 && node.parent.name === node) { - return false; - } - if (node.parent.kind === 202) { - var parent = node.parent; - if (parent.left === node && parent.operatorToken.kind === 58) { - return false; - } - } - var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol || !symbol.declarations) { - return false; - } - var declaration = symbol.declarations[0]; - if (!declaration) { - return false; - } - if (declaration.kind !== 235) { - return false; - } - var statement = declaration.parent.parent; - return (statement.parent.kind === 277); - } - function onSubstituteNode(hint, node) { - node = previousOnSubstituteNode(hint, node); - if (ts.isIdentifier(node) && isDefinedConstant(node)) { - var nodeText = ts.getTextOfIdentifierOrLiteral(node); - return ts.createIdentifier(compilerDefines[nodeText]); - } - return node; - } - } - ts.transformTypeScriptPlus = transformTypeScriptPlus; - var reflectHelper = { - name: "typescript:reflect", - scoped: false, - priority: 0, - text: "\n var __reflect = (this && this.__reflect) || function (p, c, t) {\n p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;\n };" - }; - function createReflectHelper(context, name, fullClassName, interfaces) { - context.requestEmitHelper(reflectHelper); - var argumentsArray = [ - ts.createPropertyAccess(name, ts.createIdentifier("prototype")), - ts.createLiteral(fullClassName) - ]; - if (interfaces.length) { - var elements = []; - for (var _i = 0, interfaces_1 = interfaces; _i < interfaces_1.length; _i++) { - var value = interfaces_1[_i]; - elements.push(ts.createLiteral(value)); - } - argumentsArray.push(ts.createArrayLiteral(elements)); - } - return ts.createCall(ts.getHelperName("__reflect"), undefined, argumentsArray); - } -})(ts || (ts = {})); -var ts; -(function (ts) { - var checker; - var sourceFiles; - var rootFileNames; - var dependencyMap; - var pathWeightMap; - var visitedBlocks; - var calledMethods = []; - function createMap() { - var map = Object.create(null); - map["__"] = undefined; - delete map["__"]; - return map; - } - function reorderSourceFiles(program) { - sourceFiles = program.getSourceFiles(); - rootFileNames = program.getRootFileNames(); - checker = program.getTypeChecker(); - visitedBlocks = []; - buildDependencyMap(); - var result = sortOnDependency(); - sourceFiles = []; - rootFileNames = []; - checker = null; - dependencyMap = null; - visitedBlocks = []; - return result; - } - ts.reorderSourceFiles = reorderSourceFiles; - function addDependency(file, dependent) { - if (file == dependent) { - return; - } - var list = dependencyMap[file]; - if (!list) { - list = dependencyMap[file] = []; - } - if (list.indexOf(dependent) == -1) { - list.push(dependent); - } - } - function buildDependencyMap() { - dependencyMap = createMap(); - for (var i = 0; i < sourceFiles.length; i++) { - var sourceFile = sourceFiles[i]; - if (sourceFile.isDeclarationFile) { - continue; - } - visitFile(sourceFile); - } - } - function visitFile(sourceFile) { - var statements = sourceFile.statements; - var length = statements.length; - for (var i = 0; i < length; i++) { - var statement = statements[i]; - if (ts.hasModifier(statement, 2)) { - continue; - } - visitStatement(statements[i]); - } - } - function visitStatement(statement) { - if (!statement) { - return; - } - switch (statement.kind) { - case 219: - var expression = statement; - visitExpression(expression.expression); - break; - case 238: - checkInheriting(statement); - visitStaticMember(statement); - if (statement.transformFlags & 4096) { - visitClassDecorators(statement); - } - break; - case 217: - visitVariableList(statement.declarationList); - break; - case 246: - var importDeclaration = statement; - checkDependencyAtLocation(importDeclaration.moduleReference); - break; - case 242: - visitModule(statement); - break; - case 216: - visitBlock(statement); - break; - case 220: - var ifStatement = statement; - visitExpression(ifStatement.expression); - visitStatement(ifStatement.thenStatement); - visitStatement(ifStatement.elseStatement); - break; - case 221: - case 222: - case 229: - var doStatement = statement; - visitExpression(doStatement.expression); - visitStatement(doStatement.statement); - break; - case 223: - var forStatement = statement; - visitExpression(forStatement.condition); - visitExpression(forStatement.incrementor); - if (forStatement.initializer) { - if (forStatement.initializer.kind === 236) { - visitVariableList(forStatement.initializer); - } - else { - visitExpression(forStatement.initializer); - } - } - break; - case 224: - case 225: - var forInStatement = statement; - visitExpression(forInStatement.expression); - if (forInStatement.initializer) { - if (forInStatement.initializer.kind === 236) { - visitVariableList(forInStatement.initializer); - } - else { - visitExpression(forInStatement.initializer); - } - } - break; - case 228: - visitExpression(statement.expression); - break; - case 230: - var switchStatment = statement; - visitExpression(switchStatment.expression); - switchStatment.caseBlock.clauses.forEach(function (element) { - if (element.kind === 269) { - visitExpression(element.expression); - } - element.statements.forEach(function (element) { - visitStatement(element); - }); - }); - break; - case 231: - visitStatement(statement.statement); - break; - case 232: - visitExpression(statement.expression); - break; - case 233: - var tryStatement = statement; - visitBlock(tryStatement.tryBlock); - visitBlock(tryStatement.finallyBlock); - if (tryStatement.catchClause) { - visitBlock(tryStatement.catchClause.block); - } - break; - } - } - function visitModule(node) { - if (node.body.kind === 242) { - visitModule(node.body); - return; - } - if (node.body.kind === 243) { - for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (ts.hasModifier(statement, 2)) { - continue; - } - visitStatement(statement); - } - } - } - function checkDependencyAtLocation(node) { - var symbol = checker.getSymbolAtLocation(node); - if (!symbol || !symbol.declarations) { - return; - } - var sourceFile = getSourceFileOfNode(symbol.declarations[0]); - if (!sourceFile || sourceFile.isDeclarationFile) { - return; - } - addDependency(getSourceFileOfNode(node).fileName, sourceFile.fileName); - } - function checkInheriting(node) { - if (!node.heritageClauses) { - return; - } - var heritageClause = null; - for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { - var clause = _a[_i]; - if (clause.token === 85) { - heritageClause = clause; - break; - } - } - if (!heritageClause) { - return; - } - var superClasses = heritageClause.types; - if (!superClasses) { - return; - } - superClasses.forEach(function (superClass) { - checkDependencyAtLocation(superClass.expression); - }); - } - function visitStaticMember(node) { - var members = node.members; - if (!members) { - return; - } - for (var _i = 0, members_6 = members; _i < members_6.length; _i++) { - var member = members_6[_i]; - if (!ts.hasModifier(member, 32)) { - continue; - } - if (member.kind == 152) { - var property = member; - visitExpression(property.initializer); - } - } - } - function visitClassDecorators(node) { - if (node.decorators) { - visitDecorators(node.decorators); - } - var members = node.members; - if (!members) { - return; - } - for (var _i = 0, members_7 = members; _i < members_7.length; _i++) { - var member = members_7[_i]; - var decorators = void 0; - var functionLikeMember = void 0; - if (member.kind === 156 || member.kind === 157) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member !== accessors.firstAccessor) { - continue; - } - decorators = accessors.firstAccessor.decorators; - if (!decorators && accessors.secondAccessor) { - decorators = accessors.secondAccessor.decorators; - } - functionLikeMember = accessors.setAccessor; - } - else { - decorators = member.decorators; - if (member.kind === 154) { - functionLikeMember = member; - } - } - if (decorators) { - visitDecorators(decorators); - } - if (functionLikeMember) { - for (var _a = 0, _b = functionLikeMember.parameters; _a < _b.length; _a++) { - var parameter = _b[_a]; - if (parameter.decorators) { - visitDecorators(parameter.decorators); - } - } - } - } - } - function visitDecorators(decorators) { - for (var _i = 0, decorators_2 = decorators; _i < decorators_2.length; _i++) { - var decorator = decorators_2[_i]; - visitCallExpression(decorator.expression); - } - } - function visitExpression(expression) { - if (!expression) { - return; - } - switch (expression.kind) { - case 190: - case 189: - visitCallArguments(expression); - visitCallExpression(expression.expression); - break; - case 71: - checkDependencyAtLocation(expression); - break; - case 187: - checkDependencyAtLocation(expression); - break; - case 188: - visitExpression(expression.expression); - break; - case 186: - visitObjectLiteralExpression(expression); - break; - case 185: - var arrayLiteral = expression; - arrayLiteral.elements.forEach(visitExpression); - break; - case 204: - var template = expression; - template.templateSpans.forEach(function (span) { - visitExpression(span.expression); - }); - break; - case 193: - var parenthesized = expression; - visitExpression(parenthesized.expression); - break; - case 202: - visitBinaryExpression(expression); - break; - case 201: - case 200: - visitExpression(expression.operand); - break; - case 196: - visitExpression(expression.expression); - break; - case 191: - visitExpression(expression.tag); - visitExpression(expression.template); - break; - case 203: - visitExpression(expression.condition); - visitExpression(expression.whenTrue); - visitExpression(expression.whenFalse); - break; - case 206: - visitExpression(expression.expression); - break; - case 198: - visitExpression(expression.expression); - break; - case 205: - visitExpression(expression.expression); - break; - case 199: - visitExpression(expression.expression); - break; - case 197: - visitExpression(expression.expression); - break; - case 211: - visitExpression(expression.expression); - break; - case 192: - visitExpression(expression.expression); - break; - } - } - function visitBinaryExpression(binary) { - var left = binary.left; - var right = binary.right; - visitExpression(left); - visitExpression(right); - if (binary.operatorToken.kind === 58 && - (left.kind === 71 || left.kind === 187) && - (right.kind === 71 || right.kind === 187)) { - var symbol = checker.getSymbolAtLocation(left); - if (!symbol || !symbol.declarations) { - return; - } - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 235 || declaration.kind === 152) { - var variable = declaration; - if (variable.initializer) { - continue; - } - if (!variable.delayInitializerList) { - variable.delayInitializerList = []; - } - variable.delayInitializerList.push(right); - if (variable.callerList) { - for (var _b = 0, _c = variable.callerList; _b < _c.length; _b++) { - var callerFileName = _c[_b]; - checkCallTarget(callerFileName, right); - } - } - } - } - } - } - function visitObjectLiteralExpression(objectLiteral) { - objectLiteral.properties.forEach(function (element) { - switch (element.kind) { - case 273: - visitExpression(element.initializer); - break; - case 274: - visitExpression(element.objectAssignmentInitializer); - break; - case 275: - visitExpression(element.expression); - break; - } - }); - } - function visitCallArguments(callExpression) { - if (callExpression.arguments) { - callExpression.arguments.forEach(function (argument) { - visitExpression(argument); - }); - } - } - function visitCallExpression(expression) { - expression = escapeParenthesized(expression); - visitExpression(expression); - switch (expression.kind) { - case 194: - var functionExpression = expression; - visitBlock(functionExpression.body); - break; - case 187: - case 71: - var callerFileName = getSourceFileOfNode(expression).fileName; - checkCallTarget(callerFileName, expression); - break; - case 189: - visitReturnedFunction(expression.expression); - break; - } - } - function visitReturnedFunction(expression) { - expression = escapeParenthesized(expression); - var returnExpressions = []; - if (expression.kind === 189) { - var expressions = visitReturnedFunction(expression.expression); - for (var _i = 0, expressions_2 = expressions; _i < expressions_2.length; _i++) { - var returnExpression = expressions_2[_i]; - var returns = visitReturnedFunction(returnExpression); - returnExpressions = returnExpressions.concat(returns); - } - return returnExpressions; - } - var functionBlocks = []; - switch (expression.kind) { - case 194: - functionBlocks.push(expression.body); - break; - case 187: - case 71: - var callerFileName = getSourceFileOfNode(expression).fileName; - var declarations = []; - getForwardDeclarations(expression, declarations, callerFileName); - for (var _a = 0, declarations_11 = declarations; _a < declarations_11.length; _a++) { - var declaration = declarations_11[_a]; - var sourceFile = getSourceFileOfNode(declaration); - if (!sourceFile || sourceFile.isDeclarationFile) { - continue; - } - if (declaration.kind === 237 || - declaration.kind === 154) { - functionBlocks.push(declaration.body); - } - } - break; - } - for (var _b = 0, functionBlocks_1 = functionBlocks; _b < functionBlocks_1.length; _b++) { - var block = functionBlocks_1[_b]; - for (var _c = 0, _d = block.statements; _c < _d.length; _c++) { - var statement = _d[_c]; - if (statement.kind === 228) { - var returnExpression = statement.expression; - returnExpressions.push(returnExpression); - visitCallExpression(returnExpression); - } - } - } - return returnExpressions; - } - function escapeParenthesized(expression) { - if (expression.kind === 193) { - return escapeParenthesized(expression.expression); - } - return expression; - } - function checkCallTarget(callerFileName, target) { - var declarations = []; - getForwardDeclarations(target, declarations, callerFileName); - for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { - var declaration = declarations_12[_i]; - var sourceFile = getSourceFileOfNode(declaration); - if (!sourceFile || sourceFile.isDeclarationFile) { - continue; - } - addDependency(callerFileName, sourceFile.fileName); - if (declaration.kind === 237) { - visitBlock(declaration.body); - } - else if (declaration.kind === 154) { - visitBlock(declaration.body); - calledMethods.push(declaration); - } - else if (declaration.kind === 238) { - checkClassInstantiation(declaration); - } - } - } - function getForwardDeclarations(reference, declarations, callerFileName) { - var symbol = checker.getSymbolAtLocation(reference); - if (!symbol || !symbol.declarations) { - return; - } - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - switch (declaration.kind) { - case 237: - case 154: - case 238: - if (declarations.indexOf(declaration) == -1) { - declarations.push(declaration); - } - break; - case 246: - getForwardDeclarations(declaration.moduleReference, declarations, callerFileName); - break; - case 235: - case 152: - var variable = declaration; - var initializer = variable.initializer; - if (initializer) { - if (initializer.kind === 71 || initializer.kind === 187) { - getForwardDeclarations(initializer, declarations, callerFileName); - } - } - else { - if (variable.delayInitializerList) { - for (var _b = 0, _c = variable.delayInitializerList; _b < _c.length; _b++) { - var expression = _c[_b]; - getForwardDeclarations(expression, declarations, callerFileName); - } - } - if (variable.callerList) { - if (variable.callerList.indexOf(callerFileName) == -1) { - variable.callerList.push(callerFileName); - } - } - else { - variable.callerList = [callerFileName]; - } - } - break; - } - } - } - function checkClassInstantiation(node) { - var methodNames = []; - var superClass = ts.getClassExtendsHeritageElement(node); - if (superClass) { - var type = checker.getTypeAtLocation(superClass); - if (type && type.symbol) { - var declaration = ts.getDeclarationOfKind(type.symbol, 238); - if (declaration) { - methodNames = checkClassInstantiation(declaration); - } - } - } - var members = node.members; - if (!members) { - return []; - } - var index = calledMethods.length; - for (var _i = 0, members_8 = members; _i < members_8.length; _i++) { - var member = members_8[_i]; - if (ts.hasModifier(member, 32)) { - continue; - } - if (member.kind === 154) { - var methodName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name)); - if (methodNames.indexOf(methodName) != -1) { - visitBlock(member.body); - } - } - if (member.kind === 152) { - var property = member; - visitExpression(property.initializer); - } - else if (member.kind === 155) { - var constructor = member; - visitBlock(constructor.body); - } - } - for (var i = index; i < calledMethods.length; i++) { - var method = calledMethods[i]; - for (var _a = 0, members_9 = members; _a < members_9.length; _a++) { - var memeber = members_9[_a]; - if (memeber === method) { - var methodName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(method.name)); - methodNames.push(methodName); - } - } - } - if (index == 0) { - calledMethods.length = 0; - } - return methodNames; - } - function visitBlock(block) { - if (!block || visitedBlocks.indexOf(block) != -1) { - return; - } - visitedBlocks.push(block); - for (var _i = 0, _a = block.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - visitStatement(statement); - } - visitedBlocks.pop(); - } - function visitVariableList(variables) { - if (!variables) { - return; - } - variables.declarations.forEach(function (declaration) { - visitExpression(declaration.initializer); - }); - } - function sortOnDependency() { - var result = {}; - result.sortedFileNames = []; - result.circularReferences = []; - pathWeightMap = createMap(); - var dtsFiles = []; - var tsFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var path = sourceFile.fileName; - if (sourceFile.isDeclarationFile) { - pathWeightMap[path] = 10000; - dtsFiles.push(sourceFile); - continue; - } - var references = updatePathWeight(path, 0, [path]); - if (references.length > 0) { - result.circularReferences = references; - break; - } - tsFiles.push(sourceFile); - } - if (result.circularReferences.length === 0) { - tsFiles.sort(function (a, b) { - return pathWeightMap[b.fileName] - pathWeightMap[a.fileName]; - }); - sourceFiles.length = 0; - rootFileNames.length = 0; - dtsFiles.concat(tsFiles).forEach(function (sourceFile) { - sourceFiles.push(sourceFile); - rootFileNames.push(sourceFile.fileName); - result.sortedFileNames.push(sourceFile.fileName); - }); - } - pathWeightMap = null; - return result; - } - function updatePathWeight(path, weight, references) { - if (pathWeightMap[path] === undefined) { - pathWeightMap[path] = weight; - } - else { - if (pathWeightMap[path] < weight) { - pathWeightMap[path] = weight; - } - else { - return []; - } - } - var list = dependencyMap[path]; - if (!list) { - return []; - } - for (var _i = 0, list_3 = list; _i < list_3.length; _i++) { - var parentPath = list_3[_i]; - if (references.indexOf(parentPath) != -1) { - references.push(parentPath); - return references; - } - var result = updatePathWeight(parentPath, weight + 1, references.concat(parentPath)); - if (result.length > 0) { - return result; - } - } - return []; - } - function getSourceFileOfNode(node) { - while (node && node.kind !== 277) { - node = node.parent; - } - return node; - } -})(ts || (ts = {})); -var ts; (function (ts) { var defaultLastEncodedSourceMapSpan = { emittedLine: 0, @@ -66036,8 +64968,8 @@ var ts; } } else { - for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { - var sourceFile = sourceFiles_2[_a]; + for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { + var sourceFile = sourceFiles_1[_a]; var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); if (result) { return result; @@ -70228,7 +69160,7 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - 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, getTypeChecker: program.getTypeChecker, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + 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, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { var path = toPath(f); if (getSourceFileByPath(path)) return true; @@ -71060,8 +69992,8 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var sourceFile = sourceFiles_2[_i]; if (!sourceFile.isDeclarationFile) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -74850,21 +73782,7 @@ var ts; configFileParsingDiagnostics: configFileParsingDiagnostics }; var program = ts.createProgram(programOptions); - var exitStatus = ts.ExitStatus.Success; - if (options.reorderFiles) { - var sortResult = ts.reorderSourceFiles(program); - if (sortResult.circularReferences.length > 0) { - var errorText = ""; - errorText += "error: Find circular dependencies when reordering file :" + ts.sys.newLine; - errorText += " at " + sortResult.circularReferences.join(ts.sys.newLine + " at ") + ts.sys.newLine + " at ..."; - ts.sys.write(errorText + ts.sys.newLine); - exitStatus = ts.ExitStatus.DiagnosticsPresent_OutputsGenerated; - } - } - var exitCode = ts.emitFilesAndReportErrors(program, reportDiagnostic, function (s) { return ts.sys.write(s + ts.sys.newLine); }); - if (exitCode != ts.ExitStatus.Success) { - exitStatus = exitCode; - } + var exitStatus = ts.emitFilesAndReportErrors(program, reportDiagnostic, function (s) { return ts.sys.write(s + ts.sys.newLine); }); reportStatistics(program); return ts.sys.exit(exitStatus); } diff --git a/lib/tsserver.js b/lib/tsserver.js index 118c1b6f2..db331e39c 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -88,8 +88,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.1"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".3"; - ts.version_plus = "3.1.5"; + ts.version = ts.versionMajorMinor + ".5"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -6095,6 +6094,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { return token >= 71 /* Identifier */; @@ -6105,136 +6105,85 @@ var ts; return token === 29 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; - var textToToken = ts.createMapFromTemplate({ - "abstract": 117 /* AbstractKeyword */, - "any": 119 /* AnyKeyword */, - "as": 118 /* AsKeyword */, - "boolean": 122 /* BooleanKeyword */, - "break": 72 /* BreakKeyword */, - "case": 73 /* CaseKeyword */, - "catch": 74 /* CatchKeyword */, - "class": 75 /* ClassKeyword */, - "continue": 77 /* ContinueKeyword */, - "const": 76 /* ConstKeyword */, - "constructor": 123 /* ConstructorKeyword */, - "debugger": 78 /* DebuggerKeyword */, - "declare": 124 /* DeclareKeyword */, - "default": 79 /* DefaultKeyword */, - "delete": 80 /* DeleteKeyword */, - "do": 81 /* DoKeyword */, - "else": 82 /* ElseKeyword */, - "enum": 83 /* EnumKeyword */, - "export": 84 /* ExportKeyword */, - "extends": 85 /* ExtendsKeyword */, - "false": 86 /* FalseKeyword */, - "finally": 87 /* FinallyKeyword */, - "for": 88 /* ForKeyword */, - "from": 143 /* FromKeyword */, - "function": 89 /* FunctionKeyword */, - "get": 125 /* GetKeyword */, - "if": 90 /* IfKeyword */, - "implements": 108 /* ImplementsKeyword */, - "import": 91 /* ImportKeyword */, - "in": 92 /* InKeyword */, - "infer": 126 /* InferKeyword */, - "instanceof": 93 /* InstanceOfKeyword */, - "interface": 109 /* InterfaceKeyword */, - "is": 127 /* IsKeyword */, - "keyof": 128 /* KeyOfKeyword */, - "let": 110 /* LetKeyword */, - "module": 129 /* ModuleKeyword */, - "namespace": 130 /* NamespaceKeyword */, - "never": 131 /* NeverKeyword */, - "new": 94 /* NewKeyword */, - "null": 95 /* NullKeyword */, - "number": 134 /* NumberKeyword */, - "object": 135 /* ObjectKeyword */, - "package": 111 /* PackageKeyword */, - "private": 112 /* PrivateKeyword */, - "protected": 113 /* ProtectedKeyword */, - "public": 114 /* PublicKeyword */, - "readonly": 132 /* ReadonlyKeyword */, - "require": 133 /* RequireKeyword */, - "global": 144 /* GlobalKeyword */, - "return": 96 /* ReturnKeyword */, - "set": 136 /* SetKeyword */, - "static": 115 /* StaticKeyword */, - "string": 137 /* StringKeyword */, - "super": 97 /* SuperKeyword */, - "switch": 98 /* SwitchKeyword */, - "symbol": 138 /* SymbolKeyword */, - "this": 99 /* ThisKeyword */, - "throw": 100 /* ThrowKeyword */, - "true": 101 /* TrueKeyword */, - "try": 102 /* TryKeyword */, - "type": 139 /* TypeKeyword */, - "typeof": 103 /* TypeOfKeyword */, - "undefined": 140 /* UndefinedKeyword */, - "unique": 141 /* UniqueKeyword */, - "unknown": 142 /* UnknownKeyword */, - "var": 104 /* VarKeyword */, - "void": 105 /* VoidKeyword */, - "while": 106 /* WhileKeyword */, - "with": 107 /* WithKeyword */, - "yield": 116 /* YieldKeyword */, - "async": 120 /* AsyncKeyword */, - "await": 121 /* AwaitKeyword */, - "of": 145 /* OfKeyword */, - "{": 17 /* OpenBraceToken */, - "}": 18 /* CloseBraceToken */, - "(": 19 /* OpenParenToken */, - ")": 20 /* CloseParenToken */, - "[": 21 /* OpenBracketToken */, - "]": 22 /* CloseBracketToken */, - ".": 23 /* DotToken */, - "...": 24 /* DotDotDotToken */, - ";": 25 /* SemicolonToken */, - ",": 26 /* CommaToken */, - "<": 27 /* LessThanToken */, - ">": 29 /* GreaterThanToken */, - "<=": 30 /* LessThanEqualsToken */, - ">=": 31 /* GreaterThanEqualsToken */, - "==": 32 /* EqualsEqualsToken */, - "!=": 33 /* ExclamationEqualsToken */, - "===": 34 /* EqualsEqualsEqualsToken */, - "!==": 35 /* ExclamationEqualsEqualsToken */, - "=>": 36 /* EqualsGreaterThanToken */, - "+": 37 /* PlusToken */, - "-": 38 /* MinusToken */, - "**": 40 /* AsteriskAsteriskToken */, - "*": 39 /* AsteriskToken */, - "/": 41 /* SlashToken */, - "%": 42 /* PercentToken */, - "++": 43 /* PlusPlusToken */, - "--": 44 /* MinusMinusToken */, - "<<": 45 /* LessThanLessThanToken */, - ">": 46 /* GreaterThanGreaterThanToken */, - ">>>": 47 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 48 /* AmpersandToken */, - "|": 49 /* BarToken */, - "^": 50 /* CaretToken */, - "!": 51 /* ExclamationToken */, - "~": 52 /* TildeToken */, - "&&": 53 /* AmpersandAmpersandToken */, - "||": 54 /* BarBarToken */, - "?": 55 /* QuestionToken */, - ":": 56 /* ColonToken */, - "=": 58 /* EqualsToken */, - "+=": 59 /* PlusEqualsToken */, - "-=": 60 /* MinusEqualsToken */, - "*=": 61 /* AsteriskEqualsToken */, - "**=": 62 /* AsteriskAsteriskEqualsToken */, - "/=": 63 /* SlashEqualsToken */, - "%=": 64 /* PercentEqualsToken */, - "<<=": 65 /* LessThanLessThanEqualsToken */, - ">>=": 66 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 68 /* AmpersandEqualsToken */, - "|=": 69 /* BarEqualsToken */, - "^=": 70 /* CaretEqualsToken */, - "@": 57 /* AtToken */, - }); + var textToKeywordObj = (_a = { + abstract: 117 /* AbstractKeyword */, + any: 119 /* AnyKeyword */, + as: 118 /* AsKeyword */, + boolean: 122 /* BooleanKeyword */, + break: 72 /* BreakKeyword */, + case: 73 /* CaseKeyword */, + catch: 74 /* CatchKeyword */, + class: 75 /* ClassKeyword */, + continue: 77 /* ContinueKeyword */, + const: 76 /* ConstKeyword */ + }, + _a["" + "constructor"] = 123 /* ConstructorKeyword */, + _a.debugger = 78 /* DebuggerKeyword */, + _a.declare = 124 /* DeclareKeyword */, + _a.default = 79 /* DefaultKeyword */, + _a.delete = 80 /* DeleteKeyword */, + _a.do = 81 /* DoKeyword */, + _a.else = 82 /* ElseKeyword */, + _a.enum = 83 /* EnumKeyword */, + _a.export = 84 /* ExportKeyword */, + _a.extends = 85 /* ExtendsKeyword */, + _a.false = 86 /* FalseKeyword */, + _a.finally = 87 /* FinallyKeyword */, + _a.for = 88 /* ForKeyword */, + _a.from = 143 /* FromKeyword */, + _a.function = 89 /* FunctionKeyword */, + _a.get = 125 /* GetKeyword */, + _a.if = 90 /* IfKeyword */, + _a.implements = 108 /* ImplementsKeyword */, + _a.import = 91 /* ImportKeyword */, + _a.in = 92 /* InKeyword */, + _a.infer = 126 /* InferKeyword */, + _a.instanceof = 93 /* InstanceOfKeyword */, + _a.interface = 109 /* InterfaceKeyword */, + _a.is = 127 /* IsKeyword */, + _a.keyof = 128 /* KeyOfKeyword */, + _a.let = 110 /* LetKeyword */, + _a.module = 129 /* ModuleKeyword */, + _a.namespace = 130 /* NamespaceKeyword */, + _a.never = 131 /* NeverKeyword */, + _a.new = 94 /* NewKeyword */, + _a.null = 95 /* NullKeyword */, + _a.number = 134 /* NumberKeyword */, + _a.object = 135 /* ObjectKeyword */, + _a.package = 111 /* PackageKeyword */, + _a.private = 112 /* PrivateKeyword */, + _a.protected = 113 /* ProtectedKeyword */, + _a.public = 114 /* PublicKeyword */, + _a.readonly = 132 /* ReadonlyKeyword */, + _a.require = 133 /* RequireKeyword */, + _a.global = 144 /* GlobalKeyword */, + _a.return = 96 /* ReturnKeyword */, + _a.set = 136 /* SetKeyword */, + _a.static = 115 /* StaticKeyword */, + _a.string = 137 /* StringKeyword */, + _a.super = 97 /* SuperKeyword */, + _a.switch = 98 /* SwitchKeyword */, + _a.symbol = 138 /* SymbolKeyword */, + _a.this = 99 /* ThisKeyword */, + _a.throw = 100 /* ThrowKeyword */, + _a.true = 101 /* TrueKeyword */, + _a.try = 102 /* TryKeyword */, + _a.type = 139 /* TypeKeyword */, + _a.typeof = 103 /* TypeOfKeyword */, + _a.undefined = 140 /* UndefinedKeyword */, + _a.unique = 141 /* UniqueKeyword */, + _a.unknown = 142 /* UnknownKeyword */, + _a.var = 104 /* VarKeyword */, + _a.void = 105 /* VoidKeyword */, + _a.while = 106 /* WhileKeyword */, + _a.with = 107 /* WithKeyword */, + _a.yield = 116 /* YieldKeyword */, + _a.async = 120 /* AsyncKeyword */, + _a.await = 121 /* AwaitKeyword */, + _a.of = 145 /* OfKeyword */, + _a); + var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); + var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 17 /* OpenBraceToken */, "}": 18 /* CloseBraceToken */, "(": 19 /* OpenParenToken */, ")": 20 /* CloseParenToken */, "[": 21 /* OpenBracketToken */, "]": 22 /* CloseBracketToken */, ".": 23 /* DotToken */, "...": 24 /* DotDotDotToken */, ";": 25 /* SemicolonToken */, ",": 26 /* CommaToken */, "<": 27 /* LessThanToken */, ">": 29 /* GreaterThanToken */, "<=": 30 /* LessThanEqualsToken */, ">=": 31 /* GreaterThanEqualsToken */, "==": 32 /* EqualsEqualsToken */, "!=": 33 /* ExclamationEqualsToken */, "===": 34 /* EqualsEqualsEqualsToken */, "!==": 35 /* ExclamationEqualsEqualsToken */, "=>": 36 /* EqualsGreaterThanToken */, "+": 37 /* PlusToken */, "-": 38 /* MinusToken */, "**": 40 /* AsteriskAsteriskToken */, "*": 39 /* AsteriskToken */, "/": 41 /* SlashToken */, "%": 42 /* PercentToken */, "++": 43 /* PlusPlusToken */, "--": 44 /* MinusMinusToken */, "<<": 45 /* LessThanLessThanToken */, ">": 46 /* GreaterThanGreaterThanToken */, ">>>": 47 /* GreaterThanGreaterThanGreaterThanToken */, "&": 48 /* AmpersandToken */, "|": 49 /* BarToken */, "^": 50 /* CaretToken */, "!": 51 /* ExclamationToken */, "~": 52 /* TildeToken */, "&&": 53 /* AmpersandAmpersandToken */, "||": 54 /* BarBarToken */, "?": 55 /* QuestionToken */, ":": 56 /* ColonToken */, "=": 58 /* EqualsToken */, "+=": 59 /* PlusEqualsToken */, "-=": 60 /* MinusEqualsToken */, "*=": 61 /* AsteriskEqualsToken */, "**=": 62 /* AsteriskAsteriskEqualsToken */, "/=": 63 /* SlashEqualsToken */, "%=": 64 /* PercentEqualsToken */, "<<=": 65 /* LessThanLessThanEqualsToken */, ">>=": 66 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 68 /* AmpersandEqualsToken */, "|=": 69 /* BarEqualsToken */, "^=": 70 /* CaretEqualsToken */, "@": 57 /* AtToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -7240,9 +7189,9 @@ var ts; if (len >= 2 && len <= 11) { var ch = tokenValue.charCodeAt(0); if (ch >= 97 /* a */ && ch <= 122 /* z */) { - token = textToToken.get(tokenValue); - if (token !== undefined) { - return token; + var keyword = textToKeyword.get(tokenValue); + if (keyword !== undefined) { + return token = keyword; } } } @@ -7922,7 +7871,7 @@ var ts; pos++; } tokenValue = text.substring(tokenPos, pos); - return token = 71 /* Identifier */; + return token = getIdentifierToken(); } else { return token = 0 /* Unknown */; @@ -21436,7 +21385,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(281 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -21631,7 +21580,7 @@ var ts; nextJSDocToken(); } } - function skipWhitespaceOrAsterisk(next) { + function skipWhitespaceOrAsterisk() { if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range @@ -21645,7 +21594,7 @@ var ts; else if (token() === 39 /* AsteriskToken */) { precedingLineBreak = false; } - next(); + nextJSDocToken(); } } function parseTag(indent) { @@ -21653,9 +21602,8 @@ var ts; var atToken = createNode(57 /* AtToken */, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); - // Use 'nextToken' instead of 'nextJsDocToken' so we can parse a type like 'number' in `@enum number` - var tagName = parseJSDocIdentifierName(/*message*/ undefined, nextToken); - skipWhitespaceOrAsterisk(nextToken); + var tagName = parseJSDocIdentifierName(/*message*/ undefined); + skipWhitespaceOrAsterisk(); var tag; switch (tagName.escapedText) { case "augments": @@ -21792,7 +21740,7 @@ var ts; tagsEnd = tag.end; } function tryParseTypeExpression() { - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); return token() === 17 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { @@ -21826,7 +21774,7 @@ var ts; function parseParameterOrPropertyTag(atToken, tagName, target, indent) { var typeExpression = tryParseTypeExpression(); var isNameFirst = !typeExpression; - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed; skipWhitespace(); if (isNameFirst) { @@ -21945,7 +21893,7 @@ var ts; } function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); var typedefTag = createNode(302 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; @@ -22178,8 +22126,7 @@ var ts; } return entity; } - function parseJSDocIdentifierName(message, next) { - if (next === void 0) { next = nextJSDocToken; } + function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { return createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } @@ -22188,7 +22135,7 @@ var ts; var result = createNode(71 /* Identifier */, pos); result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); finishNode(result, end); - next(); + nextJSDocToken(); return result; } } @@ -23674,30 +23621,6 @@ var ts; type: "object" }, description: ts.Diagnostics.List_of_language_service_plugins - }, - // extra options - { - name: "accessorOptimization", - type: "boolean" - }, - { - // this option can only be specified in tsconfig.json - // use type = object to copy the value as-is - name: "defines", - type: "object", - isTSConfigOnly: true - }, - { - name: "emitReflection", - type: "boolean" - }, - { - name: "noEmitJs", - type: "boolean" - }, - { - name: "reorderFiles", - type: "boolean" } ]); /* @internal */ @@ -23889,7 +23812,7 @@ var ts; i++; break; case "list": - var result = parseListTypeOption(opt, args[i], errors); + var result = parseListTypeOption(opt, args[i], errors); // tslint:disable-line no-unnecessary-type-assertion options[opt.name] = result || []; if (result) { i++; @@ -24011,8 +23934,7 @@ var ts; } /* @internal */ function printVersion() { - ts.sys.write("Version : " + ts.version_plus + ts.sys.newLine); - ts.sys.write("typescript-version : " + ts.version + ts.sys.newLine); + ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + ts.sys.newLine); } ts.printVersion = printVersion; /* @internal */ @@ -24424,7 +24346,7 @@ var ts; return undefined; } else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); // tslint:disable-line no-unnecessary-type-assertion } else { return optionDefinition.type; @@ -24487,7 +24409,7 @@ var ts; case "object": return {}; default: - return option.type.keys().next().value; + return option.type.keys().next().value; // tslint:disable-line no-unnecessary-type-assertion } } function makePadding(paddingLength) { @@ -24967,7 +24889,7 @@ var ts; if (isNullOrUndefined(value)) return undefined; if (option.type === "list") { - var listOption_1 = option; + var listOption_1 = option; // tslint:disable-line no-unnecessary-type-assertion if (listOption_1.element.isFilePath || !ts.isString(listOption_1.element.type)) { return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return !!v; }); } @@ -25311,7 +25233,7 @@ var ts; case "boolean": return typeof value === "boolean" ? value : ""; case "list": - var elementType_1 = option.element; + var elementType_1 = option.element; // tslint:disable-line no-unnecessary-type-assertion return ts.isArray(value) ? value.map(function (v) { return getOptionValueWithEmptyStrings(v, elementType_1); }) : ""; default: return ts.forEachEntry(option.type, function (optionEnumValue, optionStringValue) { @@ -56149,7 +56071,8 @@ var ts; return true; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 - if (target && ts.getModifierFlags(node) & 1 /* Export */ && target.flags & 67220415 /* Value */) { + if (target && ts.getModifierFlags(node) & 1 /* Export */ && + target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -69107,7 +69030,6 @@ var ts; var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); - var typeChecker = context.getEmitHost().getTypeChecker(); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; @@ -70040,13 +69962,7 @@ var ts; statements.push(transformSemicolonClassElementToStatement(member)); break; case 154 /* MethodDeclaration */: - var method = member; - if (method.isJumpTarget || (method.original && method.original.isJumpTarget)) { - transformJumpTarget(statements, getClassMemberPrefix(node, member), member); - } - else { - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); - } + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -70064,30 +69980,6 @@ var ts; } } } - function transformJumpTarget(statements, receiver, member) { - var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); - statements.push(ts.createStatement(ts.createAssignment(memberName, member.name))); - var sourceMapRange = ts.getSourceMapRange(member); - var memberFunction = transformMethodToFunctionDeclaration(member, /*location*/ member, /*name*/ member.name); - ts.setEmitFlags(memberFunction, 1536 /* NoComments */); - ts.setSourceMapRange(memberFunction, sourceMapRange); - statements.push(memberFunction); - } - function transformMethodToFunctionDeclaration(node, location, name) { - var savedConvertedLoopState = convertedLoopState; - convertedLoopState = undefined; - var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); - var parameters = ts.visitParameterList(node.parameters, visitor, context); - var body = transformFunctionBody(node); - exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); - convertedLoopState = savedConvertedLoopState; - return ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, node.asteriskToken, name, - /*typeParameters*/ undefined, parameters, - /*type*/ undefined, body), location), - /*original*/ node); - } /** * Transforms a SemicolonClassElement into a statement for a class body function. * @@ -70155,14 +70047,18 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterExpression = createAccessorExpression(getAccessor, firstAccessor, receiver, container); - var getter = ts.createPropertyAssignment("get", getterExpression); + var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); + ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); + ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); + var getter = ts.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); } if (setAccessor) { - var setterExpression = createAccessorExpression(setAccessor, firstAccessor, receiver, container); - var setter = ts.createPropertyAssignment("set", setterExpression); + var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); + ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); + ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); + var setter = ts.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } @@ -70180,75 +70076,6 @@ var ts; return call; } /** - * If the accessor method contains only one call to another method, use that method to define the accessor directly. - */ - function createAccessorExpression(accessor, firstAccessor, receiver, container) { - var expression; - var method = compilerOptions.accessorOptimization ? getJumpTargetOfAccessor(accessor) : null; - if (method) { - var methodName = ts.getMutableClone(method.name); - ts.setEmitFlags(methodName, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); - ts.setSourceMapRange(methodName, method.name); - if (firstAccessor.pos > method.pos) { // the target method has been already emitted. - var target = ts.getMutableClone(receiver); - ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); - ts.setSourceMapRange(target, firstAccessor.name); - expression = ts.createPropertyAccess(target, methodName); - } - else { - expression = methodName; - method.isJumpTarget = true; - } - } - else { - expression = transformFunctionLikeToExpression(accessor, /*location*/ undefined, /*name*/ undefined, container); - } - ts.setSourceMapRange(expression, ts.getSourceMapRange(accessor)); - ts.setEmitFlags(expression, 512 /* NoLeadingComments */); - return expression; - } - function getJumpTargetOfAccessor(accessor) { - if (accessor.body.statements.length != 1) { - return undefined; - } - var statement = accessor.body.statements[0]; - if (statement.kind !== 219 /* ExpressionStatement */ && - statement.kind !== 228 /* ReturnStatement */) { - return undefined; - } - var expression = statement.expression; - if (expression.kind !== 189 /* CallExpression */) { - return undefined; - } - var callExpression = expression; - if (accessor.kind === 157 /* SetAccessor */) { - if (callExpression.arguments.length != 1) { - return undefined; - } - var argument = callExpression.arguments[0]; - if (argument.kind !== 71 /* Identifier */) { - return undefined; - } - } - else { - if (callExpression.arguments.length != 0) { - return undefined; - } - } - if (callExpression.expression.kind !== 187 /* PropertyAccessExpression */) { - return undefined; - } - var propertyExpression = callExpression.expression; - if (propertyExpression.expression.kind !== 99 /* ThisKeyword */) { - return undefined; - } - var symbol = typeChecker.getSymbolAtLocation(propertyExpression.name); - if (!symbol) { - return undefined; - } - return ts.getDeclarationOfKind(symbol, 154 /* MethodDeclaration */); - } - /** * Visits an ArrowFunction and transforms it into a FunctionExpression. * * @param node An ArrowFunction node. @@ -79346,9 +79173,6 @@ var ts; var moduleKind = ts.getEmitModuleKind(compilerOptions); var transformers = []; ts.addRange(transformers, customTransformers && customTransformers.before); - if (compilerOptions.defines || compilerOptions.emitReflection) { - transformers.push(ts.transformTypeScriptPlus); - } transformers.push(ts.transformTypeScript); if (jsx === 2 /* React */) { transformers.push(ts.transformJsx); @@ -79645,976 +79469,6 @@ var ts; } ts.transformNodes = transformNodes; })(ts || (ts = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// The MIT License (MIT) -// -// Copyright (c) 2015-present, Dom Chen. -// All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in the -// Software without restriction, including without limitation the rights to use, copy, -// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, -// and to permit persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -////////////////////////////////////////////////////////////////////////////////////// -/*@internal*/ -var ts; -(function (ts) { - function transformTypeScriptPlus(context) { - var compilerOptions = context.getCompilerOptions(); - var compilerDefines = getCompilerDefines(compilerOptions.defines); - var typeChecker = compilerOptions.emitReflection || compilerDefines ? context.getEmitHost().getTypeChecker() : null; - var previousOnSubstituteNode = context.onSubstituteNode; - if (compilerDefines) { - context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(71 /* Identifier */); - } - return ts.chainBundle(transformSourceFile); - function transformSourceFile(node) { - if (!compilerOptions.emitReflection) { - return node; - } - var visited = ts.updateSourceFileNode(node, ts.visitNodes(node.statements, visitStatement, ts.isStatement)); - ts.addEmitHelpers(visited, context.readEmitHelpers()); - return visited; - } - function visitStatement(node) { - if (ts.hasModifier(node, 2 /* Ambient */)) { - return node; - } - if (node.kind === 238 /* ClassDeclaration */) { - return visitClassDeclaration(node); - } - if (node.kind === 242 /* ModuleDeclaration */) { - return visitModule(node); - } - return node; - } - function visitModule(node) { - if (node.body.kind === 242 /* ModuleDeclaration */) { - return updateModuleDeclaration(node, visitModule(node.body)); - } - if (node.body.kind === 243 /* ModuleBlock */) { - var body = updateModuleBlock(node.body, ts.visitNodes(node.body.statements, visitStatement, ts.isStatement)); - return updateModuleDeclaration(node, body); - } - return node; - } - function updateModuleDeclaration(node, body) { - if (node.body !== body) { - var updated = ts.getMutableClone(node); - updated.body = body; - return ts.updateNode(updated, node); - } - return node; - } - function updateModuleBlock(node, statements) { - if (node.statements !== statements) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements); - return ts.updateNode(updated, node); - } - return node; - } - function visitClassDeclaration(node) { - var classStatement = ts.getMutableClone(node); - var statements = [classStatement]; - var interfaceMap = {}; - getImplementedInterfaces(node, interfaceMap); - var allInterfaces = Object.keys(interfaceMap); - var interfaces; - var superTypes = getSuperClassTypes(node); - if (superTypes) { - interfaces = []; - for (var _i = 0, allInterfaces_1 = allInterfaces; _i < allInterfaces_1.length; _i++) { - var type = allInterfaces_1[_i]; - if (superTypes.indexOf(type) === -1) { - interfaces.push(type); - } - } - } - else { - interfaces = allInterfaces; - } - node.typeNames = interfaces; - var fullClassName = typeChecker.getFullyQualifiedName(node.symbol); - var expression = createReflectHelper(context, node.name, fullClassName, interfaces); - ts.setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); - var statement = ts.createStatement(expression); - ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); - statements.push(statement); - return statements; - } - function getImplementedInterfaces(node, result) { - var superInterfaces = undefined; - if (node.kind === 238 /* ClassDeclaration */) { - superInterfaces = ts.getClassImplementsHeritageClauseElements(node); - } - else { - superInterfaces = ts.getInterfaceBaseTypeNodes(node); - } - if (superInterfaces) { - superInterfaces.forEach(function (superInterface) { - var type = typeChecker.getTypeAtLocation(superInterface); - if (type && type.symbol && type.symbol.flags & 64 /* Interface */) { - var symbol = type.symbol; - var fullName = typeChecker.getFullyQualifiedName(symbol); - result[fullName] = true; - var declaration = ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); - if (declaration) { - getImplementedInterfaces(declaration, result); - } - } - }); - } - } - function getSuperClassTypes(node) { - var superClass = ts.getClassExtendsHeritageElement(node); - if (!superClass) { - return undefined; - } - var type = typeChecker.getTypeAtLocation(superClass); - if (!type || !type.symbol) { - return undefined; - } - var declaration = ts.getDeclarationOfKind(type.symbol, 238 /* ClassDeclaration */); - return declaration ? declaration.typeNames : undefined; - } - function getCompilerDefines(defines) { - if (!defines) { - return null; - } - var compilerDefines = {}; - var keys = Object.keys(defines); - for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { - var key = keys_1[_i]; - var value = defines[key]; - var type = typeof value; - switch (type) { - case "boolean": - case "number": - compilerDefines[key] = value.toString(); - break; - case "string": - compilerDefines[key] = "\"" + value + "\""; - break; - } - } - if (Object.keys(compilerDefines).length == 0) { - return null; - } - return compilerDefines; - } - function isDefinedConstant(node) { - var nodeText = ts.getTextOfIdentifierOrLiteral(node); - if (compilerDefines[nodeText] === undefined) { - return false; - } - if (!node.parent) { - return false; - } - if (node.parent.kind === 235 /* VariableDeclaration */ && node.parent.name === node) { - return false; - } - if (node.parent.kind === 202 /* BinaryExpression */) { - var parent = node.parent; - if (parent.left === node && parent.operatorToken.kind === 58 /* EqualsToken */) { - return false; - } - } - var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol || !symbol.declarations) { - return false; - } - var declaration = symbol.declarations[0]; - if (!declaration) { - return false; - } - if (declaration.kind !== 235 /* VariableDeclaration */) { - return false; - } - var statement = declaration.parent.parent; - return (statement.parent.kind === 277 /* SourceFile */); - } - /** - * Hooks node substitutions. - * @param emitContext The context for the emitter. - * @param node The node to substitute. - */ - function onSubstituteNode(hint, node) { - node = previousOnSubstituteNode(hint, node); - if (ts.isIdentifier(node) && isDefinedConstant(node)) { - var nodeText = ts.getTextOfIdentifierOrLiteral(node); - return ts.createIdentifier(compilerDefines[nodeText]); - } - return node; - } - } - ts.transformTypeScriptPlus = transformTypeScriptPlus; - var reflectHelper = { - name: "typescript:reflect", - scoped: false, - priority: 0, - text: "\n var __reflect = (this && this.__reflect) || function (p, c, t) {\n p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;\n };" - }; - function createReflectHelper(context, name, fullClassName, interfaces) { - context.requestEmitHelper(reflectHelper); - var argumentsArray = [ - ts.createPropertyAccess(name, ts.createIdentifier("prototype")), - ts.createLiteral(fullClassName) - ]; - if (interfaces.length) { - var elements = []; - for (var _i = 0, interfaces_1 = interfaces; _i < interfaces_1.length; _i++) { - var value = interfaces_1[_i]; - elements.push(ts.createLiteral(value)); - } - argumentsArray.push(ts.createArrayLiteral(elements)); - } - return ts.createCall(ts.getHelperName("__reflect"), - /*typeArguments*/ undefined, argumentsArray); - } -})(ts || (ts = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// The MIT License (MIT) -// -// Copyright (c) 2015-present, Dom Chen. -// All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in the -// Software without restriction, including without limitation the rights to use, copy, -// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, -// and to permit persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -////////////////////////////////////////////////////////////////////////////////////// -var ts; -(function (ts) { - var checker; - var sourceFiles; - var rootFileNames; - var dependencyMap; - var pathWeightMap; - var visitedBlocks; - var calledMethods = []; - function createMap() { - var map = Object.create(null); - // Using 'delete' on an object causes V8 to put the object in dictionary mode. - // This disables creation of hidden classes, which are expensive when an object is - // constantly changing shape. - map["__"] = undefined; - delete map["__"]; - return map; - } - function reorderSourceFiles(program) { - sourceFiles = program.getSourceFiles(); - rootFileNames = program.getRootFileNames(); - checker = program.getTypeChecker(); - visitedBlocks = []; - buildDependencyMap(); - var result = sortOnDependency(); - sourceFiles = []; - rootFileNames = []; - checker = null; - dependencyMap = null; - visitedBlocks = []; - return result; - } - ts.reorderSourceFiles = reorderSourceFiles; - function addDependency(file, dependent) { - if (file == dependent) { - return; - } - var list = dependencyMap[file]; - if (!list) { - list = dependencyMap[file] = []; - } - if (list.indexOf(dependent) == -1) { - list.push(dependent); - } - } - function buildDependencyMap() { - dependencyMap = createMap(); - for (var i = 0; i < sourceFiles.length; i++) { - var sourceFile = sourceFiles[i]; - if (sourceFile.isDeclarationFile) { - continue; - } - visitFile(sourceFile); - } - } - function visitFile(sourceFile) { - var statements = sourceFile.statements; - var length = statements.length; - for (var i = 0; i < length; i++) { - var statement = statements[i]; - if (ts.hasModifier(statement, 2 /* Ambient */)) { // has the 'declare' keyword - continue; - } - visitStatement(statements[i]); - } - } - function visitStatement(statement) { - if (!statement) { - return; - } - switch (statement.kind) { - case 219 /* ExpressionStatement */: - var expression = statement; - visitExpression(expression.expression); - break; - case 238 /* ClassDeclaration */: - checkInheriting(statement); - visitStaticMember(statement); - if (statement.transformFlags & 4096 /* ContainsDecorators */) { - visitClassDecorators(statement); - } - break; - case 217 /* VariableStatement */: - visitVariableList(statement.declarationList); - break; - case 246 /* ImportEqualsDeclaration */: - var importDeclaration = statement; - checkDependencyAtLocation(importDeclaration.moduleReference); - break; - case 242 /* ModuleDeclaration */: - visitModule(statement); - break; - case 216 /* Block */: - visitBlock(statement); - break; - case 220 /* IfStatement */: - var ifStatement = statement; - visitExpression(ifStatement.expression); - visitStatement(ifStatement.thenStatement); - visitStatement(ifStatement.elseStatement); - break; - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - var doStatement = statement; - visitExpression(doStatement.expression); - visitStatement(doStatement.statement); - break; - case 223 /* ForStatement */: - var forStatement = statement; - visitExpression(forStatement.condition); - visitExpression(forStatement.incrementor); - if (forStatement.initializer) { - if (forStatement.initializer.kind === 236 /* VariableDeclarationList */) { - visitVariableList(forStatement.initializer); - } - else { - visitExpression(forStatement.initializer); - } - } - break; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - var forInStatement = statement; - visitExpression(forInStatement.expression); - if (forInStatement.initializer) { - if (forInStatement.initializer.kind === 236 /* VariableDeclarationList */) { - visitVariableList(forInStatement.initializer); - } - else { - visitExpression(forInStatement.initializer); - } - } - break; - case 228 /* ReturnStatement */: - visitExpression(statement.expression); - break; - case 230 /* SwitchStatement */: - var switchStatment = statement; - visitExpression(switchStatment.expression); - switchStatment.caseBlock.clauses.forEach(function (element) { - if (element.kind === 269 /* CaseClause */) { - visitExpression(element.expression); - } - element.statements.forEach(function (element) { - visitStatement(element); - }); - }); - break; - case 231 /* LabeledStatement */: - visitStatement(statement.statement); - break; - case 232 /* ThrowStatement */: - visitExpression(statement.expression); - break; - case 233 /* TryStatement */: - var tryStatement = statement; - visitBlock(tryStatement.tryBlock); - visitBlock(tryStatement.finallyBlock); - if (tryStatement.catchClause) { - visitBlock(tryStatement.catchClause.block); - } - break; - } - } - function visitModule(node) { - if (node.body.kind === 242 /* ModuleDeclaration */) { - visitModule(node.body); - return; - } - if (node.body.kind === 243 /* ModuleBlock */) { - for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (ts.hasModifier(statement, 2 /* Ambient */)) { // has the 'declare' keyword - continue; - } - visitStatement(statement); - } - } - } - function checkDependencyAtLocation(node) { - var symbol = checker.getSymbolAtLocation(node); - if (!symbol || !symbol.declarations) { - return; - } - var sourceFile = getSourceFileOfNode(symbol.declarations[0]); - if (!sourceFile || sourceFile.isDeclarationFile) { - return; - } - addDependency(getSourceFileOfNode(node).fileName, sourceFile.fileName); - } - function checkInheriting(node) { - if (!node.heritageClauses) { - return; - } - var heritageClause = null; - for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { - var clause = _a[_i]; - if (clause.token === 85 /* ExtendsKeyword */) { - heritageClause = clause; - break; - } - } - if (!heritageClause) { - return; - } - var superClasses = heritageClause.types; - if (!superClasses) { - return; - } - superClasses.forEach(function (superClass) { - checkDependencyAtLocation(superClass.expression); - }); - } - function visitStaticMember(node) { - var members = node.members; - if (!members) { - return; - } - for (var _i = 0, members_6 = members; _i < members_6.length; _i++) { - var member = members_6[_i]; - if (!ts.hasModifier(member, 32 /* Static */)) { - continue; - } - if (member.kind == 152 /* PropertyDeclaration */) { - var property = member; - visitExpression(property.initializer); - } - } - } - function visitClassDecorators(node) { - if (node.decorators) { - visitDecorators(node.decorators); - } - var members = node.members; - if (!members) { - return; - } - for (var _i = 0, members_7 = members; _i < members_7.length; _i++) { - var member = members_7[_i]; - var decorators = void 0; - var functionLikeMember = void 0; - if (member.kind === 156 /* GetAccessor */ || member.kind === 157 /* SetAccessor */) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member !== accessors.firstAccessor) { - continue; - } - decorators = accessors.firstAccessor.decorators; - if (!decorators && accessors.secondAccessor) { - decorators = accessors.secondAccessor.decorators; - } - functionLikeMember = accessors.setAccessor; - } - else { - decorators = member.decorators; - if (member.kind === 154 /* MethodDeclaration */) { - functionLikeMember = member; - } - } - if (decorators) { - visitDecorators(decorators); - } - if (functionLikeMember) { - for (var _a = 0, _b = functionLikeMember.parameters; _a < _b.length; _a++) { - var parameter = _b[_a]; - if (parameter.decorators) { - visitDecorators(parameter.decorators); - } - } - } - } - } - function visitDecorators(decorators) { - for (var _i = 0, decorators_2 = decorators; _i < decorators_2.length; _i++) { - var decorator = decorators_2[_i]; - visitCallExpression(decorator.expression); - } - } - function visitExpression(expression) { - if (!expression) { - return; - } - switch (expression.kind) { - case 190 /* NewExpression */: - case 189 /* CallExpression */: - visitCallArguments(expression); - visitCallExpression(expression.expression); - break; - case 71 /* Identifier */: - checkDependencyAtLocation(expression); - break; - case 187 /* PropertyAccessExpression */: - checkDependencyAtLocation(expression); - break; - case 188 /* ElementAccessExpression */: - visitExpression(expression.expression); - break; - case 186 /* ObjectLiteralExpression */: - visitObjectLiteralExpression(expression); - break; - case 185 /* ArrayLiteralExpression */: - var arrayLiteral = expression; - arrayLiteral.elements.forEach(visitExpression); - break; - case 204 /* TemplateExpression */: - var template = expression; - template.templateSpans.forEach(function (span) { - visitExpression(span.expression); - }); - break; - case 193 /* ParenthesizedExpression */: - var parenthesized = expression; - visitExpression(parenthesized.expression); - break; - case 202 /* BinaryExpression */: - visitBinaryExpression(expression); - break; - case 201 /* PostfixUnaryExpression */: - case 200 /* PrefixUnaryExpression */: - visitExpression(expression.operand); - break; - case 196 /* DeleteExpression */: - visitExpression(expression.expression); - break; - case 191 /* TaggedTemplateExpression */: - visitExpression(expression.tag); - visitExpression(expression.template); - break; - case 203 /* ConditionalExpression */: - visitExpression(expression.condition); - visitExpression(expression.whenTrue); - visitExpression(expression.whenFalse); - break; - case 206 /* SpreadElement */: - visitExpression(expression.expression); - break; - case 198 /* VoidExpression */: - visitExpression(expression.expression); - break; - case 205 /* YieldExpression */: - visitExpression(expression.expression); - break; - case 199 /* AwaitExpression */: - visitExpression(expression.expression); - break; - case 197 /* TypeOfExpression */: - visitExpression(expression.expression); - break; - case 211 /* NonNullExpression */: - visitExpression(expression.expression); - break; - case 192 /* TypeAssertionExpression */: - visitExpression(expression.expression); - break; - } - // FunctionExpression - // ArrowFunction - // ClassExpression - // OmittedExpression - // ExpressionWithTypeArguments - // AsExpression - } - function visitBinaryExpression(binary) { - var left = binary.left; - var right = binary.right; - visitExpression(left); - visitExpression(right); - if (binary.operatorToken.kind === 58 /* EqualsToken */ && - (left.kind === 71 /* Identifier */ || left.kind === 187 /* PropertyAccessExpression */) && - (right.kind === 71 /* Identifier */ || right.kind === 187 /* PropertyAccessExpression */)) { - var symbol = checker.getSymbolAtLocation(left); - if (!symbol || !symbol.declarations) { - return; - } - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 235 /* VariableDeclaration */ || declaration.kind === 152 /* PropertyDeclaration */) { - var variable = declaration; - if (variable.initializer) { - continue; - } - if (!variable.delayInitializerList) { - variable.delayInitializerList = []; - } - variable.delayInitializerList.push(right); - if (variable.callerList) { - for (var _b = 0, _c = variable.callerList; _b < _c.length; _b++) { - var callerFileName = _c[_b]; - checkCallTarget(callerFileName, right); - } - } - } - } - } - } - function visitObjectLiteralExpression(objectLiteral) { - objectLiteral.properties.forEach(function (element) { - switch (element.kind) { - case 273 /* PropertyAssignment */: - visitExpression(element.initializer); - break; - case 274 /* ShorthandPropertyAssignment */: - visitExpression(element.objectAssignmentInitializer); - break; - case 275 /* SpreadAssignment */: - visitExpression(element.expression); - break; - } - }); - } - function visitCallArguments(callExpression) { - if (callExpression.arguments) { - callExpression.arguments.forEach(function (argument) { - visitExpression(argument); - }); - } - } - function visitCallExpression(expression) { - expression = escapeParenthesized(expression); - visitExpression(expression); - switch (expression.kind) { - case 194 /* FunctionExpression */: - var functionExpression = expression; - visitBlock(functionExpression.body); - break; - case 187 /* PropertyAccessExpression */: - case 71 /* Identifier */: - var callerFileName = getSourceFileOfNode(expression).fileName; - checkCallTarget(callerFileName, expression); - break; - case 189 /* CallExpression */: - visitReturnedFunction(expression.expression); - break; - } - } - function visitReturnedFunction(expression) { - expression = escapeParenthesized(expression); - var returnExpressions = []; - if (expression.kind === 189 /* CallExpression */) { - var expressions = visitReturnedFunction(expression.expression); - for (var _i = 0, expressions_2 = expressions; _i < expressions_2.length; _i++) { - var returnExpression = expressions_2[_i]; - var returns = visitReturnedFunction(returnExpression); - returnExpressions = returnExpressions.concat(returns); - } - return returnExpressions; - } - var functionBlocks = []; - switch (expression.kind) { - case 194 /* FunctionExpression */: - functionBlocks.push(expression.body); - break; - case 187 /* PropertyAccessExpression */: - case 71 /* Identifier */: - var callerFileName = getSourceFileOfNode(expression).fileName; - var declarations = []; - getForwardDeclarations(expression, declarations, callerFileName); - for (var _a = 0, declarations_11 = declarations; _a < declarations_11.length; _a++) { - var declaration = declarations_11[_a]; - var sourceFile = getSourceFileOfNode(declaration); - if (!sourceFile || sourceFile.isDeclarationFile) { - continue; - } - if (declaration.kind === 237 /* FunctionDeclaration */ || - declaration.kind === 154 /* MethodDeclaration */) { - functionBlocks.push(declaration.body); - } - } - break; - } - for (var _b = 0, functionBlocks_1 = functionBlocks; _b < functionBlocks_1.length; _b++) { - var block = functionBlocks_1[_b]; - for (var _c = 0, _d = block.statements; _c < _d.length; _c++) { - var statement = _d[_c]; - if (statement.kind === 228 /* ReturnStatement */) { - var returnExpression = statement.expression; - returnExpressions.push(returnExpression); - visitCallExpression(returnExpression); - } - } - } - return returnExpressions; - } - function escapeParenthesized(expression) { - if (expression.kind === 193 /* ParenthesizedExpression */) { - return escapeParenthesized(expression.expression); - } - return expression; - } - function checkCallTarget(callerFileName, target) { - var declarations = []; - getForwardDeclarations(target, declarations, callerFileName); - for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { - var declaration = declarations_12[_i]; - var sourceFile = getSourceFileOfNode(declaration); - if (!sourceFile || sourceFile.isDeclarationFile) { - continue; - } - addDependency(callerFileName, sourceFile.fileName); - if (declaration.kind === 237 /* FunctionDeclaration */) { - visitBlock(declaration.body); - } - else if (declaration.kind === 154 /* MethodDeclaration */) { - visitBlock(declaration.body); - calledMethods.push(declaration); - } - else if (declaration.kind === 238 /* ClassDeclaration */) { - checkClassInstantiation(declaration); - } - } - } - function getForwardDeclarations(reference, declarations, callerFileName) { - var symbol = checker.getSymbolAtLocation(reference); - if (!symbol || !symbol.declarations) { - return; - } - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - switch (declaration.kind) { - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 238 /* ClassDeclaration */: - if (declarations.indexOf(declaration) == -1) { - declarations.push(declaration); - } - break; - case 246 /* ImportEqualsDeclaration */: - getForwardDeclarations(declaration.moduleReference, declarations, callerFileName); - break; - case 235 /* VariableDeclaration */: - case 152 /* PropertyDeclaration */: - var variable = declaration; - var initializer = variable.initializer; - if (initializer) { - if (initializer.kind === 71 /* Identifier */ || initializer.kind === 187 /* PropertyAccessExpression */) { - getForwardDeclarations(initializer, declarations, callerFileName); - } - } - else { - if (variable.delayInitializerList) { - for (var _b = 0, _c = variable.delayInitializerList; _b < _c.length; _b++) { - var expression = _c[_b]; - getForwardDeclarations(expression, declarations, callerFileName); - } - } - if (variable.callerList) { - if (variable.callerList.indexOf(callerFileName) == -1) { - variable.callerList.push(callerFileName); - } - } - else { - variable.callerList = [callerFileName]; - } - } - break; - } - } - } - function checkClassInstantiation(node) { - var methodNames = []; - var superClass = ts.getClassExtendsHeritageElement(node); - if (superClass) { - var type = checker.getTypeAtLocation(superClass); - if (type && type.symbol) { - var declaration = ts.getDeclarationOfKind(type.symbol, 238 /* ClassDeclaration */); - if (declaration) { - methodNames = checkClassInstantiation(declaration); - } - } - } - var members = node.members; - if (!members) { - return []; - } - var index = calledMethods.length; - for (var _i = 0, members_8 = members; _i < members_8.length; _i++) { - var member = members_8[_i]; - if (ts.hasModifier(member, 32 /* Static */)) { - continue; - } - if (member.kind === 154 /* MethodDeclaration */) { // called by super class. - var methodName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name)); - if (methodNames.indexOf(methodName) != -1) { - visitBlock(member.body); - } - } - if (member.kind === 152 /* PropertyDeclaration */) { - var property = member; - visitExpression(property.initializer); - } - else if (member.kind === 155 /* Constructor */) { - var constructor = member; - visitBlock(constructor.body); - } - } - for (var i = index; i < calledMethods.length; i++) { - var method = calledMethods[i]; - for (var _a = 0, members_9 = members; _a < members_9.length; _a++) { - var memeber = members_9[_a]; - if (memeber === method) { - var methodName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(method.name)); - methodNames.push(methodName); - } - } - } - if (index == 0) { - calledMethods.length = 0; - } - return methodNames; - } - function visitBlock(block) { - if (!block || visitedBlocks.indexOf(block) != -1) { - return; - } - visitedBlocks.push(block); - for (var _i = 0, _a = block.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - visitStatement(statement); - } - visitedBlocks.pop(); - } - function visitVariableList(variables) { - if (!variables) { - return; - } - variables.declarations.forEach(function (declaration) { - visitExpression(declaration.initializer); - }); - } - function sortOnDependency() { - var result = {}; - result.sortedFileNames = []; - result.circularReferences = []; - pathWeightMap = createMap(); - var dtsFiles = []; - var tsFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var path = sourceFile.fileName; - if (sourceFile.isDeclarationFile) { - pathWeightMap[path] = 10000; - dtsFiles.push(sourceFile); - continue; - } - var references = updatePathWeight(path, 0, [path]); - if (references.length > 0) { - result.circularReferences = references; - break; - } - tsFiles.push(sourceFile); - } - if (result.circularReferences.length === 0) { - tsFiles.sort(function (a, b) { - return pathWeightMap[b.fileName] - pathWeightMap[a.fileName]; - }); - sourceFiles.length = 0; - rootFileNames.length = 0; - dtsFiles.concat(tsFiles).forEach(function (sourceFile) { - sourceFiles.push(sourceFile); - rootFileNames.push(sourceFile.fileName); - result.sortedFileNames.push(sourceFile.fileName); - }); - } - pathWeightMap = null; - return result; - } - function updatePathWeight(path, weight, references) { - if (pathWeightMap[path] === undefined) { - pathWeightMap[path] = weight; - } - else { - if (pathWeightMap[path] < weight) { - pathWeightMap[path] = weight; - } - else { - return []; - } - } - var list = dependencyMap[path]; - if (!list) { - return []; - } - for (var _i = 0, list_3 = list; _i < list_3.length; _i++) { - var parentPath = list_3[_i]; - if (references.indexOf(parentPath) != -1) { - references.push(parentPath); - return references; - } - var result = updatePathWeight(parentPath, weight + 1, references.concat(parentPath)); - if (result.length > 0) { - return result; - } - } - return []; - } - function getSourceFileOfNode(node) { - while (node && node.kind !== 277 /* SourceFile */) { - node = node.parent; - } - return node; - } -})(ts || (ts = {})); /* @internal */ var ts; (function (ts) { @@ -81458,8 +80312,8 @@ var ts; } } else { - for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { - var sourceFile = sourceFiles_2[_a]; + for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { + var sourceFile = sourceFiles_1[_a]; var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); if (result) { return result; @@ -86130,7 +84984,7 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - 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, getTypeChecker: program.getTypeChecker, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + 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, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches var path = toPath(f); if (getSourceFileByPath(path)) @@ -87076,8 +85930,8 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var sourceFile = sourceFiles_2[_i]; if (!sourceFile.isDeclarationFile) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -99249,7 +98103,7 @@ var ts; case "compilerOptions": forEachProperty(property.initializer, function (property, propertyName) { var option = ts.getOptionFromName(propertyName); - if (option && (option.isFilePath || option.type === "list" && option.element.isFilePath)) { + if (option && (option.isFilePath || option.type === "list" && option.element.isFilePath)) { // tslint:disable-line no-unnecessary-type-assertion updatePaths(property); } else if (propertyName === "paths") { @@ -115878,11 +114732,7 @@ var ts; /// Diagnostics function getSyntacticDiagnostics(fileName) { synchronizeHostData(); - var targetSourceFile; - if (fileName) { - targetSourceFile = getValidSourceFile(fileName); - } - return program.getSyntacticDiagnostics(targetSourceFile, cancellationToken).slice(); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken).slice(); } /** * getSemanticDiagnostics return array of Diagnostics. If '-d' is not enabled, only report semantic errors @@ -115890,10 +114740,7 @@ var ts; */ function getSemanticDiagnostics(fileName) { synchronizeHostData(); - var targetSourceFile; - if (fileName) { - targetSourceFile = getValidSourceFile(fileName); - } + var targetSourceFile = getValidSourceFile(fileName); // Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file. // Therefore only get diagnostics for given file. var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); @@ -116055,10 +114902,7 @@ var ts; function getEmitOutput(fileName, emitOnlyDtsFiles) { if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } synchronizeHostData(); - var sourceFile; - if (fileName) { - sourceFile = getValidSourceFile(fileName); - } + var sourceFile = getValidSourceFile(fileName); var customTransformers = host.getCustomTransformers && host.getCustomTransformers(); return ts.getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers); } @@ -118746,6 +117590,7 @@ var ts; CommandTypes["OrganizeImportsFull"] = "organizeImports-full"; CommandTypes["GetEditsForFileRename"] = "getEditsForFileRename"; CommandTypes["GetEditsForFileRenameFull"] = "getEditsForFileRename-full"; + CommandTypes["ConfigurePlugin"] = "configurePlugin"; })(CommandTypes = protocol.CommandTypes || (protocol.CommandTypes = {})); var IndentStyle; (function (IndentStyle) { @@ -119626,10 +118471,10 @@ var ts; Project.prototype.getExternalFiles = function () { var _this = this; return server.toSortedArray(ts.flatMap(this.plugins, function (plugin) { - if (typeof plugin.getExternalFiles !== "function") + if (typeof plugin.module.getExternalFiles !== "function") return; try { - return plugin.getExternalFiles(_this); + return plugin.module.getExternalFiles(_this); } catch (e) { _this.projectService.logger.info("A plugin threw an exception in getExternalFiles: " + e); @@ -120060,7 +118905,7 @@ var ts; ts.orderedRemoveItem(this.rootFiles, info); this.rootFilesMap.delete(info.path); }; - Project.prototype.enableGlobalPlugins = function (options) { + Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) { var host = this.projectService.host; if (!host.require) { this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); @@ -120074,7 +118919,7 @@ var ts; if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; })) return "continue"; this_1.projectService.logger.info("Loading global plugin " + globalPluginName); - this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths); + this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths, pluginConfigOverrides); }; var this_1 = this; for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) { @@ -120083,7 +118928,7 @@ var ts; } } }; - Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths) { + Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) { var _this = this; this.projectService.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(",")); var log = function (message) { @@ -120093,15 +118938,18 @@ var ts; return Project.resolveModule(pluginConfigEntry.name, searchPath, _this.projectService.host, log); }); if (resolvedModule) { + var configurationOverride = pluginConfigOverrides && pluginConfigOverrides.get(pluginConfigEntry.name); + if (configurationOverride) { + var pluginName = pluginConfigEntry.name; + pluginConfigEntry = configurationOverride; + pluginConfigEntry.name = pluginName; + } this.enableProxy(resolvedModule, pluginConfigEntry); } else { this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name); } }; - Project.prototype.refreshDiagnostics = function () { - this.projectService.sendProjectsUpdatedInBackgroundEvent(); - }; Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) { try { if (typeof pluginModuleFactory !== "function") { @@ -120126,25 +118974,35 @@ var ts; } this.projectService.logger.info("Plugin validation succeded"); this.languageService = newLS; - this.plugins.push(pluginModule); + this.plugins.push({ name: configEntry.name, module: pluginModule }); } catch (e) { this.projectService.logger.info("Plugin activation failed: " + e); } }; + Project.prototype.onPluginConfigurationChanged = function (pluginName, configuration) { + this.plugins.filter(function (plugin) { return plugin.name === pluginName; }).forEach(function (plugin) { + if (plugin.module.onConfigurationChanged) { + plugin.module.onConfigurationChanged(configuration); + } + }); + }; + Project.prototype.refreshDiagnostics = function () { + this.projectService.sendProjectsUpdatedInBackgroundEvent(); + }; return Project; }()); server.Project = Project; var InferredProject = (function (_super) { __extends(InferredProject, _super); - function InferredProject(projectService, documentRegistry, compilerOptions, projectRootPath, currentDirectory) { + function InferredProject(projectService, documentRegistry, compilerOptions, projectRootPath, currentDirectory, pluginConfigOverrides) { var _this = _super.call(this, InferredProject.newName(), ProjectKind.Inferred, projectService, documentRegistry, undefined, undefined, compilerOptions, false, projectService.host, currentDirectory) || this; _this._isJsInferredProject = false; _this.projectRootPath = projectRootPath && projectService.toCanonicalFileName(projectRootPath); if (!projectRootPath && !projectService.useSingleInferredProject) { _this.canonicalCurrentDirectory = projectService.toCanonicalFileName(_this.currentDirectory); } - _this.enableGlobalPlugins(_this.getCompilerOptions()); + _this.enableGlobalPlugins(_this.getCompilerOptions(), pluginConfigOverrides); return _this; } InferredProject.prototype.toggleJsInferredProject = function (isJsInferredProject) { @@ -120259,10 +119117,7 @@ var ts; var program = this.getCurrentProgram(); return program && program.getResolvedProjectReferences(); }; - ConfiguredProject.prototype.enablePlugins = function () { - this.enablePluginsWithOptions(this.getCompilerOptions()); - }; - ConfiguredProject.prototype.enablePluginsWithOptions = function (options) { + ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) { var host = this.projectService.host; if (!host.require) { this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); @@ -120277,10 +119132,10 @@ var ts; if (options.plugins) { for (var _i = 0, _a = options.plugins; _i < _a.length; _i++) { var pluginConfigEntry = _a[_i]; - this.enablePlugin(pluginConfigEntry, searchPaths); + this.enablePlugin(pluginConfigEntry, searchPaths, pluginConfigOverrides); } } - this.enableGlobalPlugins(options); + this.enableGlobalPlugins(options, pluginConfigOverrides); }; ConfiguredProject.prototype.getGlobalProjectErrors = function () { return ts.filter(this.projectErrors, function (diagnostic) { return !diagnostic.file; }) || server.emptyArray; @@ -121409,7 +120264,7 @@ var ts; project.enableLanguageService(); project.watchWildcards(ts.createMapFromTemplate(parsedCommandLine.wildcardDirectories)); } - project.enablePluginsWithOptions(compilerOptions); + project.enablePluginsWithOptions(compilerOptions, this.currentPluginConfigOverrides); var filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles()); this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave); }; @@ -121546,7 +120401,7 @@ var ts; }; ProjectService.prototype.createInferredProject = function (currentDirectory, isSingleInferredProject, projectRootPath) { var compilerOptions = projectRootPath && this.compilerOptionsForInferredProjectsPerProjectRoot.get(projectRootPath) || this.compilerOptionsForInferredProjects; - var project = new server.InferredProject(this, this.documentRegistry, compilerOptions, projectRootPath, currentDirectory); + var project = new server.InferredProject(this, this.documentRegistry, compilerOptions, projectRootPath, currentDirectory, this.currentPluginConfigOverrides); if (isSingleInferredProject) { this.inferredProjects.unshift(project); } @@ -122289,6 +121144,11 @@ var ts; } return false; }; + ProjectService.prototype.configurePlugin = function (args) { + this.forEachEnabledProject(function (project) { return project.onPluginConfigurationChanged(args.pluginName, args.configuration); }); + this.currentPluginConfigOverrides = this.currentPluginConfigOverrides || ts.createMap(); + this.currentPluginConfigOverrides.set(args.pluginName, args.configuration); + }; ProjectService.filenameEscapeRegexp = /[-\/\\^$*+?.()|[\]{}]/g; return ProjectService; }()); @@ -122929,6 +121789,10 @@ var ts; _a[server.CommandNames.GetEditsForFileRenameFull] = function (request) { return _this.requiredResponse(_this.getEditsForFileRename(request.arguments, false)); }, + _a[server.CommandNames.ConfigurePlugin] = function (request) { + _this.configurePlugin(request.arguments); + return _this.notRequired(); + }, _a)); this.host = opts.host; this.cancellationToken = opts.cancellationToken; @@ -124149,6 +123013,9 @@ var ts; var checkList = sortedFiles.map(function (fileName) { return ({ fileName: fileName, project: project }); }); this.updateErrorCheck(next, checkList, delay, false); }; + Session.prototype.configurePlugin = function (args) { + this.projectService.configurePlugin(args); + }; Session.prototype.getCanonicalFileName = function (fileName) { var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); return ts.normalizePath(name); diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index 38a4ee816..1d56e9020 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -17,7 +17,6 @@ declare namespace ts { const versionMajorMinor = "3.1"; /** The version of the TypeScript compiler release */ const version: string; - const version_plus = "3.1.5"; } declare namespace ts { /** @@ -70,7 +69,8 @@ declare namespace ts { pos: number; end: number; } - type JsDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.Unknown; + type JsDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.Unknown | KeywordSyntaxKind; + type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; enum SyntaxKind { Unknown = 0, @@ -692,7 +692,6 @@ declare namespace ts { parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; - isJumpTarget?: boolean; } interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; @@ -1333,7 +1332,6 @@ declare namespace ts { typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; - typeNames?: string[]; } interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.ClassDeclaration; @@ -2509,11 +2507,6 @@ declare namespace ts { /** Paths used to compute primary types search locations */ typeRoots?: string[]; esModuleInterop?: boolean; - accessorOptimization?: boolean; - defines?: MapLike; - emitReflection?: boolean; - noEmitJs?: boolean; - reorderFiles?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } interface TypeAcquisition { @@ -4147,13 +4140,6 @@ declare namespace ts { */ function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; } -declare namespace ts { - interface SortingResult { - sortedFileNames: string[]; - circularReferences: string[]; - } - function reorderSourceFiles(program: Program): SortingResult; -} declare namespace ts { function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } @@ -5687,7 +5673,8 @@ declare namespace ts.server.protocol { GetApplicableRefactors = "getApplicableRefactors", GetEditsForRefactor = "getEditsForRefactor", OrganizeImports = "organizeImports", - GetEditsForFileRename = "getEditsForFileRename" + GetEditsForFileRename = "getEditsForFileRename", + ConfigurePlugin = "configurePlugin" } /** * A TypeScript Server message @@ -6632,6 +6619,14 @@ declare namespace ts.server.protocol { */ interface ConfigureResponse extends Response { } + interface ConfigurePluginRequestArguments { + pluginName: string; + configuration: any; + } + interface ConfigurePluginRequest extends Request { + command: CommandTypes.ConfigurePlugin; + arguments: ConfigurePluginRequestArguments; + } /** * Information found in an "open" request. */ @@ -8058,6 +8053,11 @@ declare namespace ts.server { interface PluginModule { create(createInfo: PluginCreateInfo): LanguageService; getExternalFiles?(proj: Project): string[]; + onConfigurationChanged?(config: any): void; + } + interface PluginModuleWithName { + name: string; + module: PluginModule; } type PluginModuleFactory = (mod: { typescript: typeof ts; @@ -8196,11 +8196,11 @@ declare namespace ts.server { filesToString(writeProjectFileNames: boolean): string; setCompilerOptions(compilerOptions: CompilerOptions): void; protected removeRoot(info: ScriptInfo): void; - protected enableGlobalPlugins(options: CompilerOptions): void; - protected enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[]): void; + protected enableGlobalPlugins(options: CompilerOptions, pluginConfigOverrides: Map | undefined): void; + protected enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[], pluginConfigOverrides: Map | undefined): void; + private enableProxy; /** Starts a new check for diagnostics. Call this if some file has updated that would cause diagnostics to be changed. */ refreshDiagnostics(): void; - private enableProxy; } /** * If a file is opened and no tsconfig (or jsconfig) is found, @@ -8241,7 +8241,6 @@ declare namespace ts.server { getConfigFilePath(): NormalizedPath; getProjectReferences(): ReadonlyArray; updateReferences(refs: ReadonlyArray | undefined): void; - enablePlugins(): void; /** * Get the errors that dont have any file name associated */ @@ -8486,6 +8485,7 @@ declare namespace ts.server { readonly globalPlugins: ReadonlyArray; readonly pluginProbeLocations: ReadonlyArray; readonly allowLocalPluginLoads: boolean; + private currentPluginConfigOverrides; readonly typesMapLocation: string | undefined; readonly syntaxOnly?: boolean; /** Tracks projects that we have already sent telemetry for. */ @@ -8661,6 +8661,7 @@ declare namespace ts.server { applySafeList(proj: protocol.ExternalProject): NormalizedPath[]; openExternalProject(proj: protocol.ExternalProject): void; hasDeferredExtension(): boolean; + configurePlugin(args: protocol.ConfigurePluginRequestArguments): void; } } declare namespace ts.server { @@ -8831,6 +8832,7 @@ declare namespace ts.server { private convertTextChangeToCodeEdit; private getBraceMatching; private getDiagnosticsForProject; + private configurePlugin; getCanonicalFileName(fileName: string): string; exit(): void; private notRequired; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 3ac1ed785..36154ec24 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -84,8 +84,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.1"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".3"; - ts.version_plus = "3.1.5"; + ts.version = ts.versionMajorMinor + ".5"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -6091,6 +6090,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { return token >= 71 /* Identifier */; @@ -6101,136 +6101,85 @@ var ts; return token === 29 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; - var textToToken = ts.createMapFromTemplate({ - "abstract": 117 /* AbstractKeyword */, - "any": 119 /* AnyKeyword */, - "as": 118 /* AsKeyword */, - "boolean": 122 /* BooleanKeyword */, - "break": 72 /* BreakKeyword */, - "case": 73 /* CaseKeyword */, - "catch": 74 /* CatchKeyword */, - "class": 75 /* ClassKeyword */, - "continue": 77 /* ContinueKeyword */, - "const": 76 /* ConstKeyword */, - "constructor": 123 /* ConstructorKeyword */, - "debugger": 78 /* DebuggerKeyword */, - "declare": 124 /* DeclareKeyword */, - "default": 79 /* DefaultKeyword */, - "delete": 80 /* DeleteKeyword */, - "do": 81 /* DoKeyword */, - "else": 82 /* ElseKeyword */, - "enum": 83 /* EnumKeyword */, - "export": 84 /* ExportKeyword */, - "extends": 85 /* ExtendsKeyword */, - "false": 86 /* FalseKeyword */, - "finally": 87 /* FinallyKeyword */, - "for": 88 /* ForKeyword */, - "from": 143 /* FromKeyword */, - "function": 89 /* FunctionKeyword */, - "get": 125 /* GetKeyword */, - "if": 90 /* IfKeyword */, - "implements": 108 /* ImplementsKeyword */, - "import": 91 /* ImportKeyword */, - "in": 92 /* InKeyword */, - "infer": 126 /* InferKeyword */, - "instanceof": 93 /* InstanceOfKeyword */, - "interface": 109 /* InterfaceKeyword */, - "is": 127 /* IsKeyword */, - "keyof": 128 /* KeyOfKeyword */, - "let": 110 /* LetKeyword */, - "module": 129 /* ModuleKeyword */, - "namespace": 130 /* NamespaceKeyword */, - "never": 131 /* NeverKeyword */, - "new": 94 /* NewKeyword */, - "null": 95 /* NullKeyword */, - "number": 134 /* NumberKeyword */, - "object": 135 /* ObjectKeyword */, - "package": 111 /* PackageKeyword */, - "private": 112 /* PrivateKeyword */, - "protected": 113 /* ProtectedKeyword */, - "public": 114 /* PublicKeyword */, - "readonly": 132 /* ReadonlyKeyword */, - "require": 133 /* RequireKeyword */, - "global": 144 /* GlobalKeyword */, - "return": 96 /* ReturnKeyword */, - "set": 136 /* SetKeyword */, - "static": 115 /* StaticKeyword */, - "string": 137 /* StringKeyword */, - "super": 97 /* SuperKeyword */, - "switch": 98 /* SwitchKeyword */, - "symbol": 138 /* SymbolKeyword */, - "this": 99 /* ThisKeyword */, - "throw": 100 /* ThrowKeyword */, - "true": 101 /* TrueKeyword */, - "try": 102 /* TryKeyword */, - "type": 139 /* TypeKeyword */, - "typeof": 103 /* TypeOfKeyword */, - "undefined": 140 /* UndefinedKeyword */, - "unique": 141 /* UniqueKeyword */, - "unknown": 142 /* UnknownKeyword */, - "var": 104 /* VarKeyword */, - "void": 105 /* VoidKeyword */, - "while": 106 /* WhileKeyword */, - "with": 107 /* WithKeyword */, - "yield": 116 /* YieldKeyword */, - "async": 120 /* AsyncKeyword */, - "await": 121 /* AwaitKeyword */, - "of": 145 /* OfKeyword */, - "{": 17 /* OpenBraceToken */, - "}": 18 /* CloseBraceToken */, - "(": 19 /* OpenParenToken */, - ")": 20 /* CloseParenToken */, - "[": 21 /* OpenBracketToken */, - "]": 22 /* CloseBracketToken */, - ".": 23 /* DotToken */, - "...": 24 /* DotDotDotToken */, - ";": 25 /* SemicolonToken */, - ",": 26 /* CommaToken */, - "<": 27 /* LessThanToken */, - ">": 29 /* GreaterThanToken */, - "<=": 30 /* LessThanEqualsToken */, - ">=": 31 /* GreaterThanEqualsToken */, - "==": 32 /* EqualsEqualsToken */, - "!=": 33 /* ExclamationEqualsToken */, - "===": 34 /* EqualsEqualsEqualsToken */, - "!==": 35 /* ExclamationEqualsEqualsToken */, - "=>": 36 /* EqualsGreaterThanToken */, - "+": 37 /* PlusToken */, - "-": 38 /* MinusToken */, - "**": 40 /* AsteriskAsteriskToken */, - "*": 39 /* AsteriskToken */, - "/": 41 /* SlashToken */, - "%": 42 /* PercentToken */, - "++": 43 /* PlusPlusToken */, - "--": 44 /* MinusMinusToken */, - "<<": 45 /* LessThanLessThanToken */, - ">": 46 /* GreaterThanGreaterThanToken */, - ">>>": 47 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 48 /* AmpersandToken */, - "|": 49 /* BarToken */, - "^": 50 /* CaretToken */, - "!": 51 /* ExclamationToken */, - "~": 52 /* TildeToken */, - "&&": 53 /* AmpersandAmpersandToken */, - "||": 54 /* BarBarToken */, - "?": 55 /* QuestionToken */, - ":": 56 /* ColonToken */, - "=": 58 /* EqualsToken */, - "+=": 59 /* PlusEqualsToken */, - "-=": 60 /* MinusEqualsToken */, - "*=": 61 /* AsteriskEqualsToken */, - "**=": 62 /* AsteriskAsteriskEqualsToken */, - "/=": 63 /* SlashEqualsToken */, - "%=": 64 /* PercentEqualsToken */, - "<<=": 65 /* LessThanLessThanEqualsToken */, - ">>=": 66 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 68 /* AmpersandEqualsToken */, - "|=": 69 /* BarEqualsToken */, - "^=": 70 /* CaretEqualsToken */, - "@": 57 /* AtToken */, - }); + var textToKeywordObj = (_a = { + abstract: 117 /* AbstractKeyword */, + any: 119 /* AnyKeyword */, + as: 118 /* AsKeyword */, + boolean: 122 /* BooleanKeyword */, + break: 72 /* BreakKeyword */, + case: 73 /* CaseKeyword */, + catch: 74 /* CatchKeyword */, + class: 75 /* ClassKeyword */, + continue: 77 /* ContinueKeyword */, + const: 76 /* ConstKeyword */ + }, + _a["" + "constructor"] = 123 /* ConstructorKeyword */, + _a.debugger = 78 /* DebuggerKeyword */, + _a.declare = 124 /* DeclareKeyword */, + _a.default = 79 /* DefaultKeyword */, + _a.delete = 80 /* DeleteKeyword */, + _a.do = 81 /* DoKeyword */, + _a.else = 82 /* ElseKeyword */, + _a.enum = 83 /* EnumKeyword */, + _a.export = 84 /* ExportKeyword */, + _a.extends = 85 /* ExtendsKeyword */, + _a.false = 86 /* FalseKeyword */, + _a.finally = 87 /* FinallyKeyword */, + _a.for = 88 /* ForKeyword */, + _a.from = 143 /* FromKeyword */, + _a.function = 89 /* FunctionKeyword */, + _a.get = 125 /* GetKeyword */, + _a.if = 90 /* IfKeyword */, + _a.implements = 108 /* ImplementsKeyword */, + _a.import = 91 /* ImportKeyword */, + _a.in = 92 /* InKeyword */, + _a.infer = 126 /* InferKeyword */, + _a.instanceof = 93 /* InstanceOfKeyword */, + _a.interface = 109 /* InterfaceKeyword */, + _a.is = 127 /* IsKeyword */, + _a.keyof = 128 /* KeyOfKeyword */, + _a.let = 110 /* LetKeyword */, + _a.module = 129 /* ModuleKeyword */, + _a.namespace = 130 /* NamespaceKeyword */, + _a.never = 131 /* NeverKeyword */, + _a.new = 94 /* NewKeyword */, + _a.null = 95 /* NullKeyword */, + _a.number = 134 /* NumberKeyword */, + _a.object = 135 /* ObjectKeyword */, + _a.package = 111 /* PackageKeyword */, + _a.private = 112 /* PrivateKeyword */, + _a.protected = 113 /* ProtectedKeyword */, + _a.public = 114 /* PublicKeyword */, + _a.readonly = 132 /* ReadonlyKeyword */, + _a.require = 133 /* RequireKeyword */, + _a.global = 144 /* GlobalKeyword */, + _a.return = 96 /* ReturnKeyword */, + _a.set = 136 /* SetKeyword */, + _a.static = 115 /* StaticKeyword */, + _a.string = 137 /* StringKeyword */, + _a.super = 97 /* SuperKeyword */, + _a.switch = 98 /* SwitchKeyword */, + _a.symbol = 138 /* SymbolKeyword */, + _a.this = 99 /* ThisKeyword */, + _a.throw = 100 /* ThrowKeyword */, + _a.true = 101 /* TrueKeyword */, + _a.try = 102 /* TryKeyword */, + _a.type = 139 /* TypeKeyword */, + _a.typeof = 103 /* TypeOfKeyword */, + _a.undefined = 140 /* UndefinedKeyword */, + _a.unique = 141 /* UniqueKeyword */, + _a.unknown = 142 /* UnknownKeyword */, + _a.var = 104 /* VarKeyword */, + _a.void = 105 /* VoidKeyword */, + _a.while = 106 /* WhileKeyword */, + _a.with = 107 /* WithKeyword */, + _a.yield = 116 /* YieldKeyword */, + _a.async = 120 /* AsyncKeyword */, + _a.await = 121 /* AwaitKeyword */, + _a.of = 145 /* OfKeyword */, + _a); + var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); + var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 17 /* OpenBraceToken */, "}": 18 /* CloseBraceToken */, "(": 19 /* OpenParenToken */, ")": 20 /* CloseParenToken */, "[": 21 /* OpenBracketToken */, "]": 22 /* CloseBracketToken */, ".": 23 /* DotToken */, "...": 24 /* DotDotDotToken */, ";": 25 /* SemicolonToken */, ",": 26 /* CommaToken */, "<": 27 /* LessThanToken */, ">": 29 /* GreaterThanToken */, "<=": 30 /* LessThanEqualsToken */, ">=": 31 /* GreaterThanEqualsToken */, "==": 32 /* EqualsEqualsToken */, "!=": 33 /* ExclamationEqualsToken */, "===": 34 /* EqualsEqualsEqualsToken */, "!==": 35 /* ExclamationEqualsEqualsToken */, "=>": 36 /* EqualsGreaterThanToken */, "+": 37 /* PlusToken */, "-": 38 /* MinusToken */, "**": 40 /* AsteriskAsteriskToken */, "*": 39 /* AsteriskToken */, "/": 41 /* SlashToken */, "%": 42 /* PercentToken */, "++": 43 /* PlusPlusToken */, "--": 44 /* MinusMinusToken */, "<<": 45 /* LessThanLessThanToken */, ">": 46 /* GreaterThanGreaterThanToken */, ">>>": 47 /* GreaterThanGreaterThanGreaterThanToken */, "&": 48 /* AmpersandToken */, "|": 49 /* BarToken */, "^": 50 /* CaretToken */, "!": 51 /* ExclamationToken */, "~": 52 /* TildeToken */, "&&": 53 /* AmpersandAmpersandToken */, "||": 54 /* BarBarToken */, "?": 55 /* QuestionToken */, ":": 56 /* ColonToken */, "=": 58 /* EqualsToken */, "+=": 59 /* PlusEqualsToken */, "-=": 60 /* MinusEqualsToken */, "*=": 61 /* AsteriskEqualsToken */, "**=": 62 /* AsteriskAsteriskEqualsToken */, "/=": 63 /* SlashEqualsToken */, "%=": 64 /* PercentEqualsToken */, "<<=": 65 /* LessThanLessThanEqualsToken */, ">>=": 66 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 68 /* AmpersandEqualsToken */, "|=": 69 /* BarEqualsToken */, "^=": 70 /* CaretEqualsToken */, "@": 57 /* AtToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -7236,9 +7185,9 @@ var ts; if (len >= 2 && len <= 11) { var ch = tokenValue.charCodeAt(0); if (ch >= 97 /* a */ && ch <= 122 /* z */) { - token = textToToken.get(tokenValue); - if (token !== undefined) { - return token; + var keyword = textToKeyword.get(tokenValue); + if (keyword !== undefined) { + return token = keyword; } } } @@ -7918,7 +7867,7 @@ var ts; pos++; } tokenValue = text.substring(tokenPos, pos); - return token = 71 /* Identifier */; + return token = getIdentifierToken(); } else { return token = 0 /* Unknown */; @@ -21432,7 +21381,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(281 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -21627,7 +21576,7 @@ var ts; nextJSDocToken(); } } - function skipWhitespaceOrAsterisk(next) { + function skipWhitespaceOrAsterisk() { if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range @@ -21641,7 +21590,7 @@ var ts; else if (token() === 39 /* AsteriskToken */) { precedingLineBreak = false; } - next(); + nextJSDocToken(); } } function parseTag(indent) { @@ -21649,9 +21598,8 @@ var ts; var atToken = createNode(57 /* AtToken */, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); - // Use 'nextToken' instead of 'nextJsDocToken' so we can parse a type like 'number' in `@enum number` - var tagName = parseJSDocIdentifierName(/*message*/ undefined, nextToken); - skipWhitespaceOrAsterisk(nextToken); + var tagName = parseJSDocIdentifierName(/*message*/ undefined); + skipWhitespaceOrAsterisk(); var tag; switch (tagName.escapedText) { case "augments": @@ -21788,7 +21736,7 @@ var ts; tagsEnd = tag.end; } function tryParseTypeExpression() { - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); return token() === 17 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { @@ -21822,7 +21770,7 @@ var ts; function parseParameterOrPropertyTag(atToken, tagName, target, indent) { var typeExpression = tryParseTypeExpression(); var isNameFirst = !typeExpression; - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed; skipWhitespace(); if (isNameFirst) { @@ -21941,7 +21889,7 @@ var ts; } function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); var typedefTag = createNode(302 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; @@ -22174,8 +22122,7 @@ var ts; } return entity; } - function parseJSDocIdentifierName(message, next) { - if (next === void 0) { next = nextJSDocToken; } + function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { return createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } @@ -22184,7 +22131,7 @@ var ts; var result = createNode(71 /* Identifier */, pos); result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); finishNode(result, end); - next(); + nextJSDocToken(); return result; } } @@ -23670,30 +23617,6 @@ var ts; type: "object" }, description: ts.Diagnostics.List_of_language_service_plugins - }, - // extra options - { - name: "accessorOptimization", - type: "boolean" - }, - { - // this option can only be specified in tsconfig.json - // use type = object to copy the value as-is - name: "defines", - type: "object", - isTSConfigOnly: true - }, - { - name: "emitReflection", - type: "boolean" - }, - { - name: "noEmitJs", - type: "boolean" - }, - { - name: "reorderFiles", - type: "boolean" } ]); /* @internal */ @@ -23885,7 +23808,7 @@ var ts; i++; break; case "list": - var result = parseListTypeOption(opt, args[i], errors); + var result = parseListTypeOption(opt, args[i], errors); // tslint:disable-line no-unnecessary-type-assertion options[opt.name] = result || []; if (result) { i++; @@ -24007,8 +23930,7 @@ var ts; } /* @internal */ function printVersion() { - ts.sys.write("Version : " + ts.version_plus + ts.sys.newLine); - ts.sys.write("typescript-version : " + ts.version + ts.sys.newLine); + ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + ts.sys.newLine); } ts.printVersion = printVersion; /* @internal */ @@ -24420,7 +24342,7 @@ var ts; return undefined; } else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); // tslint:disable-line no-unnecessary-type-assertion } else { return optionDefinition.type; @@ -24483,7 +24405,7 @@ var ts; case "object": return {}; default: - return option.type.keys().next().value; + return option.type.keys().next().value; // tslint:disable-line no-unnecessary-type-assertion } } function makePadding(paddingLength) { @@ -24963,7 +24885,7 @@ var ts; if (isNullOrUndefined(value)) return undefined; if (option.type === "list") { - var listOption_1 = option; + var listOption_1 = option; // tslint:disable-line no-unnecessary-type-assertion if (listOption_1.element.isFilePath || !ts.isString(listOption_1.element.type)) { return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return !!v; }); } @@ -25307,7 +25229,7 @@ var ts; case "boolean": return typeof value === "boolean" ? value : ""; case "list": - var elementType_1 = option.element; + var elementType_1 = option.element; // tslint:disable-line no-unnecessary-type-assertion return ts.isArray(value) ? value.map(function (v) { return getOptionValueWithEmptyStrings(v, elementType_1); }) : ""; default: return ts.forEachEntry(option.type, function (optionEnumValue, optionStringValue) { @@ -56145,7 +56067,8 @@ var ts; return true; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 - if (target && ts.getModifierFlags(node) & 1 /* Export */ && target.flags & 67220415 /* Value */) { + if (target && ts.getModifierFlags(node) & 1 /* Export */ && + target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -69103,7 +69026,6 @@ var ts; var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); - var typeChecker = context.getEmitHost().getTypeChecker(); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; @@ -70036,13 +69958,7 @@ var ts; statements.push(transformSemicolonClassElementToStatement(member)); break; case 154 /* MethodDeclaration */: - var method = member; - if (method.isJumpTarget || (method.original && method.original.isJumpTarget)) { - transformJumpTarget(statements, getClassMemberPrefix(node, member), member); - } - else { - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); - } + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -70060,30 +69976,6 @@ var ts; } } } - function transformJumpTarget(statements, receiver, member) { - var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); - statements.push(ts.createStatement(ts.createAssignment(memberName, member.name))); - var sourceMapRange = ts.getSourceMapRange(member); - var memberFunction = transformMethodToFunctionDeclaration(member, /*location*/ member, /*name*/ member.name); - ts.setEmitFlags(memberFunction, 1536 /* NoComments */); - ts.setSourceMapRange(memberFunction, sourceMapRange); - statements.push(memberFunction); - } - function transformMethodToFunctionDeclaration(node, location, name) { - var savedConvertedLoopState = convertedLoopState; - convertedLoopState = undefined; - var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); - var parameters = ts.visitParameterList(node.parameters, visitor, context); - var body = transformFunctionBody(node); - exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); - convertedLoopState = savedConvertedLoopState; - return ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, node.asteriskToken, name, - /*typeParameters*/ undefined, parameters, - /*type*/ undefined, body), location), - /*original*/ node); - } /** * Transforms a SemicolonClassElement into a statement for a class body function. * @@ -70151,14 +70043,18 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterExpression = createAccessorExpression(getAccessor, firstAccessor, receiver, container); - var getter = ts.createPropertyAssignment("get", getterExpression); + var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); + ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); + ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); + var getter = ts.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); } if (setAccessor) { - var setterExpression = createAccessorExpression(setAccessor, firstAccessor, receiver, container); - var setter = ts.createPropertyAssignment("set", setterExpression); + var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); + ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); + ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); + var setter = ts.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } @@ -70176,75 +70072,6 @@ var ts; return call; } /** - * If the accessor method contains only one call to another method, use that method to define the accessor directly. - */ - function createAccessorExpression(accessor, firstAccessor, receiver, container) { - var expression; - var method = compilerOptions.accessorOptimization ? getJumpTargetOfAccessor(accessor) : null; - if (method) { - var methodName = ts.getMutableClone(method.name); - ts.setEmitFlags(methodName, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); - ts.setSourceMapRange(methodName, method.name); - if (firstAccessor.pos > method.pos) { // the target method has been already emitted. - var target = ts.getMutableClone(receiver); - ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); - ts.setSourceMapRange(target, firstAccessor.name); - expression = ts.createPropertyAccess(target, methodName); - } - else { - expression = methodName; - method.isJumpTarget = true; - } - } - else { - expression = transformFunctionLikeToExpression(accessor, /*location*/ undefined, /*name*/ undefined, container); - } - ts.setSourceMapRange(expression, ts.getSourceMapRange(accessor)); - ts.setEmitFlags(expression, 512 /* NoLeadingComments */); - return expression; - } - function getJumpTargetOfAccessor(accessor) { - if (accessor.body.statements.length != 1) { - return undefined; - } - var statement = accessor.body.statements[0]; - if (statement.kind !== 219 /* ExpressionStatement */ && - statement.kind !== 228 /* ReturnStatement */) { - return undefined; - } - var expression = statement.expression; - if (expression.kind !== 189 /* CallExpression */) { - return undefined; - } - var callExpression = expression; - if (accessor.kind === 157 /* SetAccessor */) { - if (callExpression.arguments.length != 1) { - return undefined; - } - var argument = callExpression.arguments[0]; - if (argument.kind !== 71 /* Identifier */) { - return undefined; - } - } - else { - if (callExpression.arguments.length != 0) { - return undefined; - } - } - if (callExpression.expression.kind !== 187 /* PropertyAccessExpression */) { - return undefined; - } - var propertyExpression = callExpression.expression; - if (propertyExpression.expression.kind !== 99 /* ThisKeyword */) { - return undefined; - } - var symbol = typeChecker.getSymbolAtLocation(propertyExpression.name); - if (!symbol) { - return undefined; - } - return ts.getDeclarationOfKind(symbol, 154 /* MethodDeclaration */); - } - /** * Visits an ArrowFunction and transforms it into a FunctionExpression. * * @param node An ArrowFunction node. @@ -79342,9 +79169,6 @@ var ts; var moduleKind = ts.getEmitModuleKind(compilerOptions); var transformers = []; ts.addRange(transformers, customTransformers && customTransformers.before); - if (compilerOptions.defines || compilerOptions.emitReflection) { - transformers.push(ts.transformTypeScriptPlus); - } transformers.push(ts.transformTypeScript); if (jsx === 2 /* React */) { transformers.push(ts.transformJsx); @@ -79641,976 +79465,6 @@ var ts; } ts.transformNodes = transformNodes; })(ts || (ts = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// The MIT License (MIT) -// -// Copyright (c) 2015-present, Dom Chen. -// All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in the -// Software without restriction, including without limitation the rights to use, copy, -// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, -// and to permit persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -////////////////////////////////////////////////////////////////////////////////////// -/*@internal*/ -var ts; -(function (ts) { - function transformTypeScriptPlus(context) { - var compilerOptions = context.getCompilerOptions(); - var compilerDefines = getCompilerDefines(compilerOptions.defines); - var typeChecker = compilerOptions.emitReflection || compilerDefines ? context.getEmitHost().getTypeChecker() : null; - var previousOnSubstituteNode = context.onSubstituteNode; - if (compilerDefines) { - context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(71 /* Identifier */); - } - return ts.chainBundle(transformSourceFile); - function transformSourceFile(node) { - if (!compilerOptions.emitReflection) { - return node; - } - var visited = ts.updateSourceFileNode(node, ts.visitNodes(node.statements, visitStatement, ts.isStatement)); - ts.addEmitHelpers(visited, context.readEmitHelpers()); - return visited; - } - function visitStatement(node) { - if (ts.hasModifier(node, 2 /* Ambient */)) { - return node; - } - if (node.kind === 238 /* ClassDeclaration */) { - return visitClassDeclaration(node); - } - if (node.kind === 242 /* ModuleDeclaration */) { - return visitModule(node); - } - return node; - } - function visitModule(node) { - if (node.body.kind === 242 /* ModuleDeclaration */) { - return updateModuleDeclaration(node, visitModule(node.body)); - } - if (node.body.kind === 243 /* ModuleBlock */) { - var body = updateModuleBlock(node.body, ts.visitNodes(node.body.statements, visitStatement, ts.isStatement)); - return updateModuleDeclaration(node, body); - } - return node; - } - function updateModuleDeclaration(node, body) { - if (node.body !== body) { - var updated = ts.getMutableClone(node); - updated.body = body; - return ts.updateNode(updated, node); - } - return node; - } - function updateModuleBlock(node, statements) { - if (node.statements !== statements) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements); - return ts.updateNode(updated, node); - } - return node; - } - function visitClassDeclaration(node) { - var classStatement = ts.getMutableClone(node); - var statements = [classStatement]; - var interfaceMap = {}; - getImplementedInterfaces(node, interfaceMap); - var allInterfaces = Object.keys(interfaceMap); - var interfaces; - var superTypes = getSuperClassTypes(node); - if (superTypes) { - interfaces = []; - for (var _i = 0, allInterfaces_1 = allInterfaces; _i < allInterfaces_1.length; _i++) { - var type = allInterfaces_1[_i]; - if (superTypes.indexOf(type) === -1) { - interfaces.push(type); - } - } - } - else { - interfaces = allInterfaces; - } - node.typeNames = interfaces; - var fullClassName = typeChecker.getFullyQualifiedName(node.symbol); - var expression = createReflectHelper(context, node.name, fullClassName, interfaces); - ts.setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); - var statement = ts.createStatement(expression); - ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); - statements.push(statement); - return statements; - } - function getImplementedInterfaces(node, result) { - var superInterfaces = undefined; - if (node.kind === 238 /* ClassDeclaration */) { - superInterfaces = ts.getClassImplementsHeritageClauseElements(node); - } - else { - superInterfaces = ts.getInterfaceBaseTypeNodes(node); - } - if (superInterfaces) { - superInterfaces.forEach(function (superInterface) { - var type = typeChecker.getTypeAtLocation(superInterface); - if (type && type.symbol && type.symbol.flags & 64 /* Interface */) { - var symbol = type.symbol; - var fullName = typeChecker.getFullyQualifiedName(symbol); - result[fullName] = true; - var declaration = ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); - if (declaration) { - getImplementedInterfaces(declaration, result); - } - } - }); - } - } - function getSuperClassTypes(node) { - var superClass = ts.getClassExtendsHeritageElement(node); - if (!superClass) { - return undefined; - } - var type = typeChecker.getTypeAtLocation(superClass); - if (!type || !type.symbol) { - return undefined; - } - var declaration = ts.getDeclarationOfKind(type.symbol, 238 /* ClassDeclaration */); - return declaration ? declaration.typeNames : undefined; - } - function getCompilerDefines(defines) { - if (!defines) { - return null; - } - var compilerDefines = {}; - var keys = Object.keys(defines); - for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { - var key = keys_1[_i]; - var value = defines[key]; - var type = typeof value; - switch (type) { - case "boolean": - case "number": - compilerDefines[key] = value.toString(); - break; - case "string": - compilerDefines[key] = "\"" + value + "\""; - break; - } - } - if (Object.keys(compilerDefines).length == 0) { - return null; - } - return compilerDefines; - } - function isDefinedConstant(node) { - var nodeText = ts.getTextOfIdentifierOrLiteral(node); - if (compilerDefines[nodeText] === undefined) { - return false; - } - if (!node.parent) { - return false; - } - if (node.parent.kind === 235 /* VariableDeclaration */ && node.parent.name === node) { - return false; - } - if (node.parent.kind === 202 /* BinaryExpression */) { - var parent = node.parent; - if (parent.left === node && parent.operatorToken.kind === 58 /* EqualsToken */) { - return false; - } - } - var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol || !symbol.declarations) { - return false; - } - var declaration = symbol.declarations[0]; - if (!declaration) { - return false; - } - if (declaration.kind !== 235 /* VariableDeclaration */) { - return false; - } - var statement = declaration.parent.parent; - return (statement.parent.kind === 277 /* SourceFile */); - } - /** - * Hooks node substitutions. - * @param emitContext The context for the emitter. - * @param node The node to substitute. - */ - function onSubstituteNode(hint, node) { - node = previousOnSubstituteNode(hint, node); - if (ts.isIdentifier(node) && isDefinedConstant(node)) { - var nodeText = ts.getTextOfIdentifierOrLiteral(node); - return ts.createIdentifier(compilerDefines[nodeText]); - } - return node; - } - } - ts.transformTypeScriptPlus = transformTypeScriptPlus; - var reflectHelper = { - name: "typescript:reflect", - scoped: false, - priority: 0, - text: "\n var __reflect = (this && this.__reflect) || function (p, c, t) {\n p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;\n };" - }; - function createReflectHelper(context, name, fullClassName, interfaces) { - context.requestEmitHelper(reflectHelper); - var argumentsArray = [ - ts.createPropertyAccess(name, ts.createIdentifier("prototype")), - ts.createLiteral(fullClassName) - ]; - if (interfaces.length) { - var elements = []; - for (var _i = 0, interfaces_1 = interfaces; _i < interfaces_1.length; _i++) { - var value = interfaces_1[_i]; - elements.push(ts.createLiteral(value)); - } - argumentsArray.push(ts.createArrayLiteral(elements)); - } - return ts.createCall(ts.getHelperName("__reflect"), - /*typeArguments*/ undefined, argumentsArray); - } -})(ts || (ts = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// The MIT License (MIT) -// -// Copyright (c) 2015-present, Dom Chen. -// All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in the -// Software without restriction, including without limitation the rights to use, copy, -// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, -// and to permit persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -////////////////////////////////////////////////////////////////////////////////////// -var ts; -(function (ts) { - var checker; - var sourceFiles; - var rootFileNames; - var dependencyMap; - var pathWeightMap; - var visitedBlocks; - var calledMethods = []; - function createMap() { - var map = Object.create(null); - // Using 'delete' on an object causes V8 to put the object in dictionary mode. - // This disables creation of hidden classes, which are expensive when an object is - // constantly changing shape. - map["__"] = undefined; - delete map["__"]; - return map; - } - function reorderSourceFiles(program) { - sourceFiles = program.getSourceFiles(); - rootFileNames = program.getRootFileNames(); - checker = program.getTypeChecker(); - visitedBlocks = []; - buildDependencyMap(); - var result = sortOnDependency(); - sourceFiles = []; - rootFileNames = []; - checker = null; - dependencyMap = null; - visitedBlocks = []; - return result; - } - ts.reorderSourceFiles = reorderSourceFiles; - function addDependency(file, dependent) { - if (file == dependent) { - return; - } - var list = dependencyMap[file]; - if (!list) { - list = dependencyMap[file] = []; - } - if (list.indexOf(dependent) == -1) { - list.push(dependent); - } - } - function buildDependencyMap() { - dependencyMap = createMap(); - for (var i = 0; i < sourceFiles.length; i++) { - var sourceFile = sourceFiles[i]; - if (sourceFile.isDeclarationFile) { - continue; - } - visitFile(sourceFile); - } - } - function visitFile(sourceFile) { - var statements = sourceFile.statements; - var length = statements.length; - for (var i = 0; i < length; i++) { - var statement = statements[i]; - if (ts.hasModifier(statement, 2 /* Ambient */)) { // has the 'declare' keyword - continue; - } - visitStatement(statements[i]); - } - } - function visitStatement(statement) { - if (!statement) { - return; - } - switch (statement.kind) { - case 219 /* ExpressionStatement */: - var expression = statement; - visitExpression(expression.expression); - break; - case 238 /* ClassDeclaration */: - checkInheriting(statement); - visitStaticMember(statement); - if (statement.transformFlags & 4096 /* ContainsDecorators */) { - visitClassDecorators(statement); - } - break; - case 217 /* VariableStatement */: - visitVariableList(statement.declarationList); - break; - case 246 /* ImportEqualsDeclaration */: - var importDeclaration = statement; - checkDependencyAtLocation(importDeclaration.moduleReference); - break; - case 242 /* ModuleDeclaration */: - visitModule(statement); - break; - case 216 /* Block */: - visitBlock(statement); - break; - case 220 /* IfStatement */: - var ifStatement = statement; - visitExpression(ifStatement.expression); - visitStatement(ifStatement.thenStatement); - visitStatement(ifStatement.elseStatement); - break; - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - var doStatement = statement; - visitExpression(doStatement.expression); - visitStatement(doStatement.statement); - break; - case 223 /* ForStatement */: - var forStatement = statement; - visitExpression(forStatement.condition); - visitExpression(forStatement.incrementor); - if (forStatement.initializer) { - if (forStatement.initializer.kind === 236 /* VariableDeclarationList */) { - visitVariableList(forStatement.initializer); - } - else { - visitExpression(forStatement.initializer); - } - } - break; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - var forInStatement = statement; - visitExpression(forInStatement.expression); - if (forInStatement.initializer) { - if (forInStatement.initializer.kind === 236 /* VariableDeclarationList */) { - visitVariableList(forInStatement.initializer); - } - else { - visitExpression(forInStatement.initializer); - } - } - break; - case 228 /* ReturnStatement */: - visitExpression(statement.expression); - break; - case 230 /* SwitchStatement */: - var switchStatment = statement; - visitExpression(switchStatment.expression); - switchStatment.caseBlock.clauses.forEach(function (element) { - if (element.kind === 269 /* CaseClause */) { - visitExpression(element.expression); - } - element.statements.forEach(function (element) { - visitStatement(element); - }); - }); - break; - case 231 /* LabeledStatement */: - visitStatement(statement.statement); - break; - case 232 /* ThrowStatement */: - visitExpression(statement.expression); - break; - case 233 /* TryStatement */: - var tryStatement = statement; - visitBlock(tryStatement.tryBlock); - visitBlock(tryStatement.finallyBlock); - if (tryStatement.catchClause) { - visitBlock(tryStatement.catchClause.block); - } - break; - } - } - function visitModule(node) { - if (node.body.kind === 242 /* ModuleDeclaration */) { - visitModule(node.body); - return; - } - if (node.body.kind === 243 /* ModuleBlock */) { - for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (ts.hasModifier(statement, 2 /* Ambient */)) { // has the 'declare' keyword - continue; - } - visitStatement(statement); - } - } - } - function checkDependencyAtLocation(node) { - var symbol = checker.getSymbolAtLocation(node); - if (!symbol || !symbol.declarations) { - return; - } - var sourceFile = getSourceFileOfNode(symbol.declarations[0]); - if (!sourceFile || sourceFile.isDeclarationFile) { - return; - } - addDependency(getSourceFileOfNode(node).fileName, sourceFile.fileName); - } - function checkInheriting(node) { - if (!node.heritageClauses) { - return; - } - var heritageClause = null; - for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { - var clause = _a[_i]; - if (clause.token === 85 /* ExtendsKeyword */) { - heritageClause = clause; - break; - } - } - if (!heritageClause) { - return; - } - var superClasses = heritageClause.types; - if (!superClasses) { - return; - } - superClasses.forEach(function (superClass) { - checkDependencyAtLocation(superClass.expression); - }); - } - function visitStaticMember(node) { - var members = node.members; - if (!members) { - return; - } - for (var _i = 0, members_6 = members; _i < members_6.length; _i++) { - var member = members_6[_i]; - if (!ts.hasModifier(member, 32 /* Static */)) { - continue; - } - if (member.kind == 152 /* PropertyDeclaration */) { - var property = member; - visitExpression(property.initializer); - } - } - } - function visitClassDecorators(node) { - if (node.decorators) { - visitDecorators(node.decorators); - } - var members = node.members; - if (!members) { - return; - } - for (var _i = 0, members_7 = members; _i < members_7.length; _i++) { - var member = members_7[_i]; - var decorators = void 0; - var functionLikeMember = void 0; - if (member.kind === 156 /* GetAccessor */ || member.kind === 157 /* SetAccessor */) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member !== accessors.firstAccessor) { - continue; - } - decorators = accessors.firstAccessor.decorators; - if (!decorators && accessors.secondAccessor) { - decorators = accessors.secondAccessor.decorators; - } - functionLikeMember = accessors.setAccessor; - } - else { - decorators = member.decorators; - if (member.kind === 154 /* MethodDeclaration */) { - functionLikeMember = member; - } - } - if (decorators) { - visitDecorators(decorators); - } - if (functionLikeMember) { - for (var _a = 0, _b = functionLikeMember.parameters; _a < _b.length; _a++) { - var parameter = _b[_a]; - if (parameter.decorators) { - visitDecorators(parameter.decorators); - } - } - } - } - } - function visitDecorators(decorators) { - for (var _i = 0, decorators_2 = decorators; _i < decorators_2.length; _i++) { - var decorator = decorators_2[_i]; - visitCallExpression(decorator.expression); - } - } - function visitExpression(expression) { - if (!expression) { - return; - } - switch (expression.kind) { - case 190 /* NewExpression */: - case 189 /* CallExpression */: - visitCallArguments(expression); - visitCallExpression(expression.expression); - break; - case 71 /* Identifier */: - checkDependencyAtLocation(expression); - break; - case 187 /* PropertyAccessExpression */: - checkDependencyAtLocation(expression); - break; - case 188 /* ElementAccessExpression */: - visitExpression(expression.expression); - break; - case 186 /* ObjectLiteralExpression */: - visitObjectLiteralExpression(expression); - break; - case 185 /* ArrayLiteralExpression */: - var arrayLiteral = expression; - arrayLiteral.elements.forEach(visitExpression); - break; - case 204 /* TemplateExpression */: - var template = expression; - template.templateSpans.forEach(function (span) { - visitExpression(span.expression); - }); - break; - case 193 /* ParenthesizedExpression */: - var parenthesized = expression; - visitExpression(parenthesized.expression); - break; - case 202 /* BinaryExpression */: - visitBinaryExpression(expression); - break; - case 201 /* PostfixUnaryExpression */: - case 200 /* PrefixUnaryExpression */: - visitExpression(expression.operand); - break; - case 196 /* DeleteExpression */: - visitExpression(expression.expression); - break; - case 191 /* TaggedTemplateExpression */: - visitExpression(expression.tag); - visitExpression(expression.template); - break; - case 203 /* ConditionalExpression */: - visitExpression(expression.condition); - visitExpression(expression.whenTrue); - visitExpression(expression.whenFalse); - break; - case 206 /* SpreadElement */: - visitExpression(expression.expression); - break; - case 198 /* VoidExpression */: - visitExpression(expression.expression); - break; - case 205 /* YieldExpression */: - visitExpression(expression.expression); - break; - case 199 /* AwaitExpression */: - visitExpression(expression.expression); - break; - case 197 /* TypeOfExpression */: - visitExpression(expression.expression); - break; - case 211 /* NonNullExpression */: - visitExpression(expression.expression); - break; - case 192 /* TypeAssertionExpression */: - visitExpression(expression.expression); - break; - } - // FunctionExpression - // ArrowFunction - // ClassExpression - // OmittedExpression - // ExpressionWithTypeArguments - // AsExpression - } - function visitBinaryExpression(binary) { - var left = binary.left; - var right = binary.right; - visitExpression(left); - visitExpression(right); - if (binary.operatorToken.kind === 58 /* EqualsToken */ && - (left.kind === 71 /* Identifier */ || left.kind === 187 /* PropertyAccessExpression */) && - (right.kind === 71 /* Identifier */ || right.kind === 187 /* PropertyAccessExpression */)) { - var symbol = checker.getSymbolAtLocation(left); - if (!symbol || !symbol.declarations) { - return; - } - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 235 /* VariableDeclaration */ || declaration.kind === 152 /* PropertyDeclaration */) { - var variable = declaration; - if (variable.initializer) { - continue; - } - if (!variable.delayInitializerList) { - variable.delayInitializerList = []; - } - variable.delayInitializerList.push(right); - if (variable.callerList) { - for (var _b = 0, _c = variable.callerList; _b < _c.length; _b++) { - var callerFileName = _c[_b]; - checkCallTarget(callerFileName, right); - } - } - } - } - } - } - function visitObjectLiteralExpression(objectLiteral) { - objectLiteral.properties.forEach(function (element) { - switch (element.kind) { - case 273 /* PropertyAssignment */: - visitExpression(element.initializer); - break; - case 274 /* ShorthandPropertyAssignment */: - visitExpression(element.objectAssignmentInitializer); - break; - case 275 /* SpreadAssignment */: - visitExpression(element.expression); - break; - } - }); - } - function visitCallArguments(callExpression) { - if (callExpression.arguments) { - callExpression.arguments.forEach(function (argument) { - visitExpression(argument); - }); - } - } - function visitCallExpression(expression) { - expression = escapeParenthesized(expression); - visitExpression(expression); - switch (expression.kind) { - case 194 /* FunctionExpression */: - var functionExpression = expression; - visitBlock(functionExpression.body); - break; - case 187 /* PropertyAccessExpression */: - case 71 /* Identifier */: - var callerFileName = getSourceFileOfNode(expression).fileName; - checkCallTarget(callerFileName, expression); - break; - case 189 /* CallExpression */: - visitReturnedFunction(expression.expression); - break; - } - } - function visitReturnedFunction(expression) { - expression = escapeParenthesized(expression); - var returnExpressions = []; - if (expression.kind === 189 /* CallExpression */) { - var expressions = visitReturnedFunction(expression.expression); - for (var _i = 0, expressions_2 = expressions; _i < expressions_2.length; _i++) { - var returnExpression = expressions_2[_i]; - var returns = visitReturnedFunction(returnExpression); - returnExpressions = returnExpressions.concat(returns); - } - return returnExpressions; - } - var functionBlocks = []; - switch (expression.kind) { - case 194 /* FunctionExpression */: - functionBlocks.push(expression.body); - break; - case 187 /* PropertyAccessExpression */: - case 71 /* Identifier */: - var callerFileName = getSourceFileOfNode(expression).fileName; - var declarations = []; - getForwardDeclarations(expression, declarations, callerFileName); - for (var _a = 0, declarations_11 = declarations; _a < declarations_11.length; _a++) { - var declaration = declarations_11[_a]; - var sourceFile = getSourceFileOfNode(declaration); - if (!sourceFile || sourceFile.isDeclarationFile) { - continue; - } - if (declaration.kind === 237 /* FunctionDeclaration */ || - declaration.kind === 154 /* MethodDeclaration */) { - functionBlocks.push(declaration.body); - } - } - break; - } - for (var _b = 0, functionBlocks_1 = functionBlocks; _b < functionBlocks_1.length; _b++) { - var block = functionBlocks_1[_b]; - for (var _c = 0, _d = block.statements; _c < _d.length; _c++) { - var statement = _d[_c]; - if (statement.kind === 228 /* ReturnStatement */) { - var returnExpression = statement.expression; - returnExpressions.push(returnExpression); - visitCallExpression(returnExpression); - } - } - } - return returnExpressions; - } - function escapeParenthesized(expression) { - if (expression.kind === 193 /* ParenthesizedExpression */) { - return escapeParenthesized(expression.expression); - } - return expression; - } - function checkCallTarget(callerFileName, target) { - var declarations = []; - getForwardDeclarations(target, declarations, callerFileName); - for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { - var declaration = declarations_12[_i]; - var sourceFile = getSourceFileOfNode(declaration); - if (!sourceFile || sourceFile.isDeclarationFile) { - continue; - } - addDependency(callerFileName, sourceFile.fileName); - if (declaration.kind === 237 /* FunctionDeclaration */) { - visitBlock(declaration.body); - } - else if (declaration.kind === 154 /* MethodDeclaration */) { - visitBlock(declaration.body); - calledMethods.push(declaration); - } - else if (declaration.kind === 238 /* ClassDeclaration */) { - checkClassInstantiation(declaration); - } - } - } - function getForwardDeclarations(reference, declarations, callerFileName) { - var symbol = checker.getSymbolAtLocation(reference); - if (!symbol || !symbol.declarations) { - return; - } - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - switch (declaration.kind) { - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 238 /* ClassDeclaration */: - if (declarations.indexOf(declaration) == -1) { - declarations.push(declaration); - } - break; - case 246 /* ImportEqualsDeclaration */: - getForwardDeclarations(declaration.moduleReference, declarations, callerFileName); - break; - case 235 /* VariableDeclaration */: - case 152 /* PropertyDeclaration */: - var variable = declaration; - var initializer = variable.initializer; - if (initializer) { - if (initializer.kind === 71 /* Identifier */ || initializer.kind === 187 /* PropertyAccessExpression */) { - getForwardDeclarations(initializer, declarations, callerFileName); - } - } - else { - if (variable.delayInitializerList) { - for (var _b = 0, _c = variable.delayInitializerList; _b < _c.length; _b++) { - var expression = _c[_b]; - getForwardDeclarations(expression, declarations, callerFileName); - } - } - if (variable.callerList) { - if (variable.callerList.indexOf(callerFileName) == -1) { - variable.callerList.push(callerFileName); - } - } - else { - variable.callerList = [callerFileName]; - } - } - break; - } - } - } - function checkClassInstantiation(node) { - var methodNames = []; - var superClass = ts.getClassExtendsHeritageElement(node); - if (superClass) { - var type = checker.getTypeAtLocation(superClass); - if (type && type.symbol) { - var declaration = ts.getDeclarationOfKind(type.symbol, 238 /* ClassDeclaration */); - if (declaration) { - methodNames = checkClassInstantiation(declaration); - } - } - } - var members = node.members; - if (!members) { - return []; - } - var index = calledMethods.length; - for (var _i = 0, members_8 = members; _i < members_8.length; _i++) { - var member = members_8[_i]; - if (ts.hasModifier(member, 32 /* Static */)) { - continue; - } - if (member.kind === 154 /* MethodDeclaration */) { // called by super class. - var methodName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name)); - if (methodNames.indexOf(methodName) != -1) { - visitBlock(member.body); - } - } - if (member.kind === 152 /* PropertyDeclaration */) { - var property = member; - visitExpression(property.initializer); - } - else if (member.kind === 155 /* Constructor */) { - var constructor = member; - visitBlock(constructor.body); - } - } - for (var i = index; i < calledMethods.length; i++) { - var method = calledMethods[i]; - for (var _a = 0, members_9 = members; _a < members_9.length; _a++) { - var memeber = members_9[_a]; - if (memeber === method) { - var methodName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(method.name)); - methodNames.push(methodName); - } - } - } - if (index == 0) { - calledMethods.length = 0; - } - return methodNames; - } - function visitBlock(block) { - if (!block || visitedBlocks.indexOf(block) != -1) { - return; - } - visitedBlocks.push(block); - for (var _i = 0, _a = block.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - visitStatement(statement); - } - visitedBlocks.pop(); - } - function visitVariableList(variables) { - if (!variables) { - return; - } - variables.declarations.forEach(function (declaration) { - visitExpression(declaration.initializer); - }); - } - function sortOnDependency() { - var result = {}; - result.sortedFileNames = []; - result.circularReferences = []; - pathWeightMap = createMap(); - var dtsFiles = []; - var tsFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var path = sourceFile.fileName; - if (sourceFile.isDeclarationFile) { - pathWeightMap[path] = 10000; - dtsFiles.push(sourceFile); - continue; - } - var references = updatePathWeight(path, 0, [path]); - if (references.length > 0) { - result.circularReferences = references; - break; - } - tsFiles.push(sourceFile); - } - if (result.circularReferences.length === 0) { - tsFiles.sort(function (a, b) { - return pathWeightMap[b.fileName] - pathWeightMap[a.fileName]; - }); - sourceFiles.length = 0; - rootFileNames.length = 0; - dtsFiles.concat(tsFiles).forEach(function (sourceFile) { - sourceFiles.push(sourceFile); - rootFileNames.push(sourceFile.fileName); - result.sortedFileNames.push(sourceFile.fileName); - }); - } - pathWeightMap = null; - return result; - } - function updatePathWeight(path, weight, references) { - if (pathWeightMap[path] === undefined) { - pathWeightMap[path] = weight; - } - else { - if (pathWeightMap[path] < weight) { - pathWeightMap[path] = weight; - } - else { - return []; - } - } - var list = dependencyMap[path]; - if (!list) { - return []; - } - for (var _i = 0, list_3 = list; _i < list_3.length; _i++) { - var parentPath = list_3[_i]; - if (references.indexOf(parentPath) != -1) { - references.push(parentPath); - return references; - } - var result = updatePathWeight(parentPath, weight + 1, references.concat(parentPath)); - if (result.length > 0) { - return result; - } - } - return []; - } - function getSourceFileOfNode(node) { - while (node && node.kind !== 277 /* SourceFile */) { - node = node.parent; - } - return node; - } -})(ts || (ts = {})); /* @internal */ var ts; (function (ts) { @@ -81454,8 +80308,8 @@ var ts; } } else { - for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { - var sourceFile = sourceFiles_2[_a]; + for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { + var sourceFile = sourceFiles_1[_a]; var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); if (result) { return result; @@ -86126,7 +84980,7 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - 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, getTypeChecker: program.getTypeChecker, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + 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, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches var path = toPath(f); if (getSourceFileByPath(path)) @@ -87072,8 +85926,8 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var sourceFile = sourceFiles_2[_i]; if (!sourceFile.isDeclarationFile) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -97759,8 +96613,8 @@ var ts; function findModuleReferences(program, sourceFiles, searchModuleSymbol) { var refs = []; var checker = program.getTypeChecker(); - for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { - var referencingFile = sourceFiles_4[_i]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var referencingFile = sourceFiles_3[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; if (searchSourceFile.kind === 277 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { @@ -97790,8 +96644,8 @@ var ts; /** Returns a map from a module symbol Id to all import statements that directly reference the module. */ function getDirectImportsMap(sourceFiles, checker, cancellationToken) { var map = ts.createMap(); - for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { - var sourceFile = sourceFiles_5[_i]; + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); forEachImport(sourceFile, function (importDecl, moduleSpecifier) { @@ -98723,8 +97577,8 @@ var ts; return undefined; } var scope; - for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { - var declaration = declarations_13[_i]; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; var container = ts.getContainerNode(declaration); if (scope && scope !== container) { // Different declarations have different containers, bail out @@ -98773,8 +97627,8 @@ var ts; if (!signature.name || !ts.isIdentifier(signature.name)) return; var symbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(signature.name)); - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var sourceFile = sourceFiles_6[_i]; + for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { + var sourceFile = sourceFiles_5[_i]; for (var _a = 0, _b = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _a < _b.length; _a++) { var name = _b[_a]; if (!ts.isIdentifier(name) || name === signature.name || name.escapedText !== signature.name.escapedText) @@ -99439,8 +98293,8 @@ var ts; // To achieve that we will keep iterating until the result stabilizes. // Remember the last meaning lastIterationMeaning = meaning; - for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { - var declaration = declarations_14[_i]; + for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { + var declaration = declarations_12[_i]; var declarationMeaning = ts.getMeaningFromDeclaration(declaration); if (declarationMeaning & meaning) { meaning |= declarationMeaning; @@ -99563,7 +98417,7 @@ var ts; case "compilerOptions": forEachProperty(property.initializer, function (property, propertyName) { var option = ts.getOptionFromName(propertyName); - if (option && (option.isFilePath || option.type === "list" && option.element.isFilePath)) { + if (option && (option.isFilePath || option.type === "list" && option.element.isFilePath)) { // tslint:disable-line no-unnecessary-type-assertion updatePaths(property); } else if (propertyName === "paths") { @@ -100430,8 +99284,8 @@ var ts; }); }; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var sourceFile = sourceFiles_6[_i]; _loop_12(sourceFile); } rawItems.sort(compareNavigateToItems); @@ -100445,8 +99299,8 @@ var ts; if (!match) { return; // continue to next named declarations } - for (var _i = 0, declarations_15 = declarations; _i < declarations_15.length; _i++) { - var declaration = declarations_15[_i]; + for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { + var declaration = declarations_13[_i]; if (!shouldKeepItem(declaration, checker)) continue; if (patternMatcher.patternContainsDots) { @@ -111712,7 +110566,7 @@ var ts; return checker.createArrayType(recur(usageContext.numberIndexContext)); } else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { - var members_10 = ts.createUnderscoreEscapedMap(); + var members_6 = ts.createUnderscoreEscapedMap(); var callSignatures = []; var constructSignatures = []; var stringIndexInfo = void 0; @@ -111720,7 +110574,7 @@ var ts; usageContext.properties.forEach(function (context, name) { var symbol = checker.createSymbol(4 /* Property */, name); symbol.type = recur(context); - members_10.set(name, symbol); + members_6.set(name, symbol); }); } if (usageContext.callContexts) { @@ -111738,7 +110592,7 @@ var ts; if (usageContext.stringIndexContext) { stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); } - return checker.createAnonymousType(/*symbol*/ undefined, members_10, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 + return checker.createAnonymousType(/*symbol*/ undefined, members_6, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 } else { return undefined; @@ -113717,8 +112571,8 @@ var ts; ts.Debug.assert(members.length > 0); // There must be at least one child, since we extracted from one. var prevMember; var allProperties = true; - for (var _i = 0, members_11 = members; _i < members_11.length; _i++) { - var member = members_11[_i]; + for (var _i = 0, members_7 = members; _i < members_7.length; _i++) { + var member = members_7[_i]; if (member.pos > maxPos) { return prevMember || members[0]; } @@ -115504,8 +114358,8 @@ var ts; return ts.emptyArray; var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations); if (doc.length === 0 || declarations.some(hasJSDocInheritDocTag)) { - for (var _i = 0, declarations_16 = declarations; _i < declarations_16.length; _i++) { - var declaration = declarations_16[_i]; + for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { + var declaration = declarations_14[_i]; var inheritedDocs = findInheritedJSDocComments(declaration, declaration.symbol.name, checker); // TODO: GH#18217 // TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs if (inheritedDocs) @@ -116192,11 +115046,7 @@ var ts; /// Diagnostics function getSyntacticDiagnostics(fileName) { synchronizeHostData(); - var targetSourceFile; - if (fileName) { - targetSourceFile = getValidSourceFile(fileName); - } - return program.getSyntacticDiagnostics(targetSourceFile, cancellationToken).slice(); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken).slice(); } /** * getSemanticDiagnostics return array of Diagnostics. If '-d' is not enabled, only report semantic errors @@ -116204,10 +115054,7 @@ var ts; */ function getSemanticDiagnostics(fileName) { synchronizeHostData(); - var targetSourceFile; - if (fileName) { - targetSourceFile = getValidSourceFile(fileName); - } + var targetSourceFile = getValidSourceFile(fileName); // Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file. // Therefore only get diagnostics for given file. var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); @@ -116369,10 +115216,7 @@ var ts; function getEmitOutput(fileName, emitOnlyDtsFiles) { if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } synchronizeHostData(); - var sourceFile; - if (fileName) { - sourceFile = getValidSourceFile(fileName); - } + var sourceFile = getValidSourceFile(fileName); var customTransformers = host.getCustomTransformers && host.getCustomTransformers(); return ts.getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers); } @@ -118732,6 +117576,7 @@ var ts; CommandTypes["GetEditsForFileRename"] = "getEditsForFileRename"; /* @internal */ CommandTypes["GetEditsForFileRenameFull"] = "getEditsForFileRename-full"; + CommandTypes["ConfigurePlugin"] = "configurePlugin"; // NOTE: If updating this, be sure to also update `allCommandNames` in `harness/unittests/session.ts`. })(CommandTypes = protocol.CommandTypes || (protocol.CommandTypes = {})); var IndentStyle; @@ -119733,10 +118578,10 @@ var ts; Project.prototype.getExternalFiles = function () { var _this = this; return server.toSortedArray(ts.flatMap(this.plugins, function (plugin) { - if (typeof plugin.getExternalFiles !== "function") + if (typeof plugin.module.getExternalFiles !== "function") return; try { - return plugin.getExternalFiles(_this); + return plugin.module.getExternalFiles(_this); } catch (e) { _this.projectService.logger.info("A plugin threw an exception in getExternalFiles: " + e); @@ -120148,8 +118993,8 @@ var ts; var sourceFiles = this.program.getSourceFiles(); var strBuilder = "\tFiles (" + sourceFiles.length + ")\n"; if (writeProjectFileNames) { - for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { - var file = sourceFiles_8[_i]; + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var file = sourceFiles_7[_i]; strBuilder += "\t" + file.fileName + "\n"; } } @@ -120228,7 +119073,7 @@ var ts; ts.orderedRemoveItem(this.rootFiles, info); this.rootFilesMap.delete(info.path); }; - Project.prototype.enableGlobalPlugins = function (options) { + Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) { var host = this.projectService.host; if (!host.require) { this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); @@ -120247,7 +119092,7 @@ var ts; return "continue"; // Provide global: true so plugins can detect why they can't find their config this_2.projectService.logger.info("Loading global plugin " + globalPluginName); - this_2.enablePlugin({ name: globalPluginName, global: true }, searchPaths); + this_2.enablePlugin({ name: globalPluginName, global: true }, searchPaths, pluginConfigOverrides); }; var this_2 = this; // Enable global plugins with synthetic configuration entries @@ -120257,7 +119102,7 @@ var ts; } } }; - Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths) { + Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) { var _this = this; this.projectService.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(",")); var log = function (message) { @@ -120267,16 +119112,19 @@ var ts; return Project.resolveModule(pluginConfigEntry.name, searchPath, _this.projectService.host, log); }); if (resolvedModule) { + var configurationOverride = pluginConfigOverrides && pluginConfigOverrides.get(pluginConfigEntry.name); + if (configurationOverride) { + // Preserve the name property since it's immutable + var pluginName = pluginConfigEntry.name; + pluginConfigEntry = configurationOverride; + pluginConfigEntry.name = pluginName; + } this.enableProxy(resolvedModule, pluginConfigEntry); } else { this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name); } }; - /** Starts a new check for diagnostics. Call this if some file has updated that would cause diagnostics to be changed. */ - Project.prototype.refreshDiagnostics = function () { - this.projectService.sendProjectsUpdatedInBackgroundEvent(); - }; Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) { try { if (typeof pluginModuleFactory !== "function") { @@ -120301,12 +119149,24 @@ var ts; } this.projectService.logger.info("Plugin validation succeded"); this.languageService = newLS; - this.plugins.push(pluginModule); + this.plugins.push({ name: configEntry.name, module: pluginModule }); } catch (e) { this.projectService.logger.info("Plugin activation failed: " + e); } }; + /*@internal*/ + Project.prototype.onPluginConfigurationChanged = function (pluginName, configuration) { + this.plugins.filter(function (plugin) { return plugin.name === pluginName; }).forEach(function (plugin) { + if (plugin.module.onConfigurationChanged) { + plugin.module.onConfigurationChanged(configuration); + } + }); + }; + /** Starts a new check for diagnostics. Call this if some file has updated that would cause diagnostics to be changed. */ + Project.prototype.refreshDiagnostics = function () { + this.projectService.sendProjectsUpdatedInBackgroundEvent(); + }; return Project; }()); server.Project = Project; @@ -120317,7 +119177,7 @@ var ts; var InferredProject = /** @class */ (function (_super) { __extends(InferredProject, _super); /*@internal*/ - function InferredProject(projectService, documentRegistry, compilerOptions, projectRootPath, currentDirectory) { + function InferredProject(projectService, documentRegistry, compilerOptions, projectRootPath, currentDirectory, pluginConfigOverrides) { var _this = _super.call(this, InferredProject.newName(), ProjectKind.Inferred, projectService, documentRegistry, // TODO: GH#18217 /*files*/ undefined, @@ -120328,7 +119188,7 @@ var ts; if (!projectRootPath && !projectService.useSingleInferredProject) { _this.canonicalCurrentDirectory = projectService.toCanonicalFileName(_this.currentDirectory); } - _this.enableGlobalPlugins(_this.getCompilerOptions()); + _this.enableGlobalPlugins(_this.getCompilerOptions(), pluginConfigOverrides); return _this; } InferredProject.prototype.toggleJsInferredProject = function (isJsInferredProject) { @@ -120465,11 +119325,8 @@ var ts; var program = this.getCurrentProgram(); return program && program.getResolvedProjectReferences(); }; - ConfiguredProject.prototype.enablePlugins = function () { - this.enablePluginsWithOptions(this.getCompilerOptions()); - }; /*@internal*/ - ConfiguredProject.prototype.enablePluginsWithOptions = function (options) { + ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) { var host = this.projectService.host; if (!host.require) { this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); @@ -120487,10 +119344,10 @@ var ts; if (options.plugins) { for (var _i = 0, _a = options.plugins; _i < _a.length; _i++) { var pluginConfigEntry = _a[_i]; - this.enablePlugin(pluginConfigEntry, searchPaths); + this.enablePlugin(pluginConfigEntry, searchPaths, pluginConfigOverrides); } } - this.enableGlobalPlugins(options); + this.enableGlobalPlugins(options, pluginConfigOverrides); }; /** * Get the errors that dont have any file name associated @@ -121908,7 +120765,7 @@ var ts; project.enableLanguageService(); project.watchWildcards(ts.createMapFromTemplate(parsedCommandLine.wildcardDirectories)); // TODO: GH#18217 } - project.enablePluginsWithOptions(compilerOptions); + project.enablePluginsWithOptions(compilerOptions, this.currentPluginConfigOverrides); var filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles()); this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave); // TODO: GH#18217 }; @@ -122083,7 +120940,7 @@ var ts; }; ProjectService.prototype.createInferredProject = function (currentDirectory, isSingleInferredProject, projectRootPath) { var compilerOptions = projectRootPath && this.compilerOptionsForInferredProjectsPerProjectRoot.get(projectRootPath) || this.compilerOptionsForInferredProjects; - var project = new server.InferredProject(this, this.documentRegistry, compilerOptions, projectRootPath, currentDirectory); + var project = new server.InferredProject(this, this.documentRegistry, compilerOptions, projectRootPath, currentDirectory, this.currentPluginConfigOverrides); if (isSingleInferredProject) { this.inferredProjects.unshift(project); } @@ -122978,6 +121835,14 @@ var ts; } return false; }; + ProjectService.prototype.configurePlugin = function (args) { + // For any projects that already have the plugin loaded, configure the plugin + this.forEachEnabledProject(function (project) { return project.onPluginConfigurationChanged(args.pluginName, args.configuration); }); + // Also save the current configuration to pass on to any projects that are yet to be loaded. + // If a plugin is configured twice, only the latest configuration will be remembered. + this.currentPluginConfigOverrides = this.currentPluginConfigOverrides || ts.createMap(); + this.currentPluginConfigOverrides.set(args.pluginName, args.configuration); + }; /** Makes a filename safe to insert in a RegExp */ ProjectService.filenameEscapeRegexp = /[-\/\\^$*+?.()|[\]{}]/g; return ProjectService; @@ -123651,6 +122516,10 @@ var ts; _a[server.CommandNames.GetEditsForFileRenameFull] = function (request) { return _this.requiredResponse(_this.getEditsForFileRename(request.arguments, /*simplifiedResult*/ false)); }, + _a[server.CommandNames.ConfigurePlugin] = function (request) { + _this.configurePlugin(request.arguments); + return _this.notRequired(); + }, _a)); this.host = opts.host; this.cancellationToken = opts.cancellationToken; @@ -124914,6 +123783,9 @@ var ts; // doesn't require the file to be opened this.updateErrorCheck(next, checkList, delay, /*requireOpen*/ false); }; + Session.prototype.configurePlugin = function (args) { + this.projectService.configurePlugin(args); + }; Session.prototype.getCanonicalFileName = function (fileName) { var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); return ts.normalizePath(name); diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index f71ad2031..ecb745dd8 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -17,7 +17,6 @@ declare namespace ts { const versionMajorMinor = "3.1"; /** The version of the TypeScript compiler release */ const version: string; - const version_plus = "3.1.5"; } declare namespace ts { /** @@ -70,7 +69,8 @@ declare namespace ts { pos: number; end: number; } - type JsDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.Unknown; + type JsDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.Unknown | KeywordSyntaxKind; + type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; enum SyntaxKind { Unknown = 0, @@ -692,7 +692,6 @@ declare namespace ts { parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; - isJumpTarget?: boolean; } interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; @@ -1333,7 +1332,6 @@ declare namespace ts { typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; - typeNames?: string[]; } interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.ClassDeclaration; @@ -2509,11 +2507,6 @@ declare namespace ts { /** Paths used to compute primary types search locations */ typeRoots?: string[]; esModuleInterop?: boolean; - accessorOptimization?: boolean; - defines?: MapLike; - emitReflection?: boolean; - noEmitJs?: boolean; - reorderFiles?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } interface TypeAcquisition { @@ -4147,13 +4140,6 @@ declare namespace ts { */ function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; } -declare namespace ts { - interface SortingResult { - sortedFileNames: string[]; - circularReferences: string[]; - } - function reorderSourceFiles(program: Program): SortingResult; -} declare namespace ts { function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } diff --git a/lib/typescript.js b/lib/typescript.js index 7367cd46a..c65793c16 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -75,8 +75,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.1"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".3"; - ts.version_plus = "3.1.5"; + ts.version = ts.versionMajorMinor + ".5"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -6082,6 +6081,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { return token >= 71 /* Identifier */; @@ -6092,136 +6092,85 @@ var ts; return token === 29 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; - var textToToken = ts.createMapFromTemplate({ - "abstract": 117 /* AbstractKeyword */, - "any": 119 /* AnyKeyword */, - "as": 118 /* AsKeyword */, - "boolean": 122 /* BooleanKeyword */, - "break": 72 /* BreakKeyword */, - "case": 73 /* CaseKeyword */, - "catch": 74 /* CatchKeyword */, - "class": 75 /* ClassKeyword */, - "continue": 77 /* ContinueKeyword */, - "const": 76 /* ConstKeyword */, - "constructor": 123 /* ConstructorKeyword */, - "debugger": 78 /* DebuggerKeyword */, - "declare": 124 /* DeclareKeyword */, - "default": 79 /* DefaultKeyword */, - "delete": 80 /* DeleteKeyword */, - "do": 81 /* DoKeyword */, - "else": 82 /* ElseKeyword */, - "enum": 83 /* EnumKeyword */, - "export": 84 /* ExportKeyword */, - "extends": 85 /* ExtendsKeyword */, - "false": 86 /* FalseKeyword */, - "finally": 87 /* FinallyKeyword */, - "for": 88 /* ForKeyword */, - "from": 143 /* FromKeyword */, - "function": 89 /* FunctionKeyword */, - "get": 125 /* GetKeyword */, - "if": 90 /* IfKeyword */, - "implements": 108 /* ImplementsKeyword */, - "import": 91 /* ImportKeyword */, - "in": 92 /* InKeyword */, - "infer": 126 /* InferKeyword */, - "instanceof": 93 /* InstanceOfKeyword */, - "interface": 109 /* InterfaceKeyword */, - "is": 127 /* IsKeyword */, - "keyof": 128 /* KeyOfKeyword */, - "let": 110 /* LetKeyword */, - "module": 129 /* ModuleKeyword */, - "namespace": 130 /* NamespaceKeyword */, - "never": 131 /* NeverKeyword */, - "new": 94 /* NewKeyword */, - "null": 95 /* NullKeyword */, - "number": 134 /* NumberKeyword */, - "object": 135 /* ObjectKeyword */, - "package": 111 /* PackageKeyword */, - "private": 112 /* PrivateKeyword */, - "protected": 113 /* ProtectedKeyword */, - "public": 114 /* PublicKeyword */, - "readonly": 132 /* ReadonlyKeyword */, - "require": 133 /* RequireKeyword */, - "global": 144 /* GlobalKeyword */, - "return": 96 /* ReturnKeyword */, - "set": 136 /* SetKeyword */, - "static": 115 /* StaticKeyword */, - "string": 137 /* StringKeyword */, - "super": 97 /* SuperKeyword */, - "switch": 98 /* SwitchKeyword */, - "symbol": 138 /* SymbolKeyword */, - "this": 99 /* ThisKeyword */, - "throw": 100 /* ThrowKeyword */, - "true": 101 /* TrueKeyword */, - "try": 102 /* TryKeyword */, - "type": 139 /* TypeKeyword */, - "typeof": 103 /* TypeOfKeyword */, - "undefined": 140 /* UndefinedKeyword */, - "unique": 141 /* UniqueKeyword */, - "unknown": 142 /* UnknownKeyword */, - "var": 104 /* VarKeyword */, - "void": 105 /* VoidKeyword */, - "while": 106 /* WhileKeyword */, - "with": 107 /* WithKeyword */, - "yield": 116 /* YieldKeyword */, - "async": 120 /* AsyncKeyword */, - "await": 121 /* AwaitKeyword */, - "of": 145 /* OfKeyword */, - "{": 17 /* OpenBraceToken */, - "}": 18 /* CloseBraceToken */, - "(": 19 /* OpenParenToken */, - ")": 20 /* CloseParenToken */, - "[": 21 /* OpenBracketToken */, - "]": 22 /* CloseBracketToken */, - ".": 23 /* DotToken */, - "...": 24 /* DotDotDotToken */, - ";": 25 /* SemicolonToken */, - ",": 26 /* CommaToken */, - "<": 27 /* LessThanToken */, - ">": 29 /* GreaterThanToken */, - "<=": 30 /* LessThanEqualsToken */, - ">=": 31 /* GreaterThanEqualsToken */, - "==": 32 /* EqualsEqualsToken */, - "!=": 33 /* ExclamationEqualsToken */, - "===": 34 /* EqualsEqualsEqualsToken */, - "!==": 35 /* ExclamationEqualsEqualsToken */, - "=>": 36 /* EqualsGreaterThanToken */, - "+": 37 /* PlusToken */, - "-": 38 /* MinusToken */, - "**": 40 /* AsteriskAsteriskToken */, - "*": 39 /* AsteriskToken */, - "/": 41 /* SlashToken */, - "%": 42 /* PercentToken */, - "++": 43 /* PlusPlusToken */, - "--": 44 /* MinusMinusToken */, - "<<": 45 /* LessThanLessThanToken */, - ">": 46 /* GreaterThanGreaterThanToken */, - ">>>": 47 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 48 /* AmpersandToken */, - "|": 49 /* BarToken */, - "^": 50 /* CaretToken */, - "!": 51 /* ExclamationToken */, - "~": 52 /* TildeToken */, - "&&": 53 /* AmpersandAmpersandToken */, - "||": 54 /* BarBarToken */, - "?": 55 /* QuestionToken */, - ":": 56 /* ColonToken */, - "=": 58 /* EqualsToken */, - "+=": 59 /* PlusEqualsToken */, - "-=": 60 /* MinusEqualsToken */, - "*=": 61 /* AsteriskEqualsToken */, - "**=": 62 /* AsteriskAsteriskEqualsToken */, - "/=": 63 /* SlashEqualsToken */, - "%=": 64 /* PercentEqualsToken */, - "<<=": 65 /* LessThanLessThanEqualsToken */, - ">>=": 66 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 68 /* AmpersandEqualsToken */, - "|=": 69 /* BarEqualsToken */, - "^=": 70 /* CaretEqualsToken */, - "@": 57 /* AtToken */, - }); + var textToKeywordObj = (_a = { + abstract: 117 /* AbstractKeyword */, + any: 119 /* AnyKeyword */, + as: 118 /* AsKeyword */, + boolean: 122 /* BooleanKeyword */, + break: 72 /* BreakKeyword */, + case: 73 /* CaseKeyword */, + catch: 74 /* CatchKeyword */, + class: 75 /* ClassKeyword */, + continue: 77 /* ContinueKeyword */, + const: 76 /* ConstKeyword */ + }, + _a["" + "constructor"] = 123 /* ConstructorKeyword */, + _a.debugger = 78 /* DebuggerKeyword */, + _a.declare = 124 /* DeclareKeyword */, + _a.default = 79 /* DefaultKeyword */, + _a.delete = 80 /* DeleteKeyword */, + _a.do = 81 /* DoKeyword */, + _a.else = 82 /* ElseKeyword */, + _a.enum = 83 /* EnumKeyword */, + _a.export = 84 /* ExportKeyword */, + _a.extends = 85 /* ExtendsKeyword */, + _a.false = 86 /* FalseKeyword */, + _a.finally = 87 /* FinallyKeyword */, + _a.for = 88 /* ForKeyword */, + _a.from = 143 /* FromKeyword */, + _a.function = 89 /* FunctionKeyword */, + _a.get = 125 /* GetKeyword */, + _a.if = 90 /* IfKeyword */, + _a.implements = 108 /* ImplementsKeyword */, + _a.import = 91 /* ImportKeyword */, + _a.in = 92 /* InKeyword */, + _a.infer = 126 /* InferKeyword */, + _a.instanceof = 93 /* InstanceOfKeyword */, + _a.interface = 109 /* InterfaceKeyword */, + _a.is = 127 /* IsKeyword */, + _a.keyof = 128 /* KeyOfKeyword */, + _a.let = 110 /* LetKeyword */, + _a.module = 129 /* ModuleKeyword */, + _a.namespace = 130 /* NamespaceKeyword */, + _a.never = 131 /* NeverKeyword */, + _a.new = 94 /* NewKeyword */, + _a.null = 95 /* NullKeyword */, + _a.number = 134 /* NumberKeyword */, + _a.object = 135 /* ObjectKeyword */, + _a.package = 111 /* PackageKeyword */, + _a.private = 112 /* PrivateKeyword */, + _a.protected = 113 /* ProtectedKeyword */, + _a.public = 114 /* PublicKeyword */, + _a.readonly = 132 /* ReadonlyKeyword */, + _a.require = 133 /* RequireKeyword */, + _a.global = 144 /* GlobalKeyword */, + _a.return = 96 /* ReturnKeyword */, + _a.set = 136 /* SetKeyword */, + _a.static = 115 /* StaticKeyword */, + _a.string = 137 /* StringKeyword */, + _a.super = 97 /* SuperKeyword */, + _a.switch = 98 /* SwitchKeyword */, + _a.symbol = 138 /* SymbolKeyword */, + _a.this = 99 /* ThisKeyword */, + _a.throw = 100 /* ThrowKeyword */, + _a.true = 101 /* TrueKeyword */, + _a.try = 102 /* TryKeyword */, + _a.type = 139 /* TypeKeyword */, + _a.typeof = 103 /* TypeOfKeyword */, + _a.undefined = 140 /* UndefinedKeyword */, + _a.unique = 141 /* UniqueKeyword */, + _a.unknown = 142 /* UnknownKeyword */, + _a.var = 104 /* VarKeyword */, + _a.void = 105 /* VoidKeyword */, + _a.while = 106 /* WhileKeyword */, + _a.with = 107 /* WithKeyword */, + _a.yield = 116 /* YieldKeyword */, + _a.async = 120 /* AsyncKeyword */, + _a.await = 121 /* AwaitKeyword */, + _a.of = 145 /* OfKeyword */, + _a); + var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); + var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 17 /* OpenBraceToken */, "}": 18 /* CloseBraceToken */, "(": 19 /* OpenParenToken */, ")": 20 /* CloseParenToken */, "[": 21 /* OpenBracketToken */, "]": 22 /* CloseBracketToken */, ".": 23 /* DotToken */, "...": 24 /* DotDotDotToken */, ";": 25 /* SemicolonToken */, ",": 26 /* CommaToken */, "<": 27 /* LessThanToken */, ">": 29 /* GreaterThanToken */, "<=": 30 /* LessThanEqualsToken */, ">=": 31 /* GreaterThanEqualsToken */, "==": 32 /* EqualsEqualsToken */, "!=": 33 /* ExclamationEqualsToken */, "===": 34 /* EqualsEqualsEqualsToken */, "!==": 35 /* ExclamationEqualsEqualsToken */, "=>": 36 /* EqualsGreaterThanToken */, "+": 37 /* PlusToken */, "-": 38 /* MinusToken */, "**": 40 /* AsteriskAsteriskToken */, "*": 39 /* AsteriskToken */, "/": 41 /* SlashToken */, "%": 42 /* PercentToken */, "++": 43 /* PlusPlusToken */, "--": 44 /* MinusMinusToken */, "<<": 45 /* LessThanLessThanToken */, ">": 46 /* GreaterThanGreaterThanToken */, ">>>": 47 /* GreaterThanGreaterThanGreaterThanToken */, "&": 48 /* AmpersandToken */, "|": 49 /* BarToken */, "^": 50 /* CaretToken */, "!": 51 /* ExclamationToken */, "~": 52 /* TildeToken */, "&&": 53 /* AmpersandAmpersandToken */, "||": 54 /* BarBarToken */, "?": 55 /* QuestionToken */, ":": 56 /* ColonToken */, "=": 58 /* EqualsToken */, "+=": 59 /* PlusEqualsToken */, "-=": 60 /* MinusEqualsToken */, "*=": 61 /* AsteriskEqualsToken */, "**=": 62 /* AsteriskAsteriskEqualsToken */, "/=": 63 /* SlashEqualsToken */, "%=": 64 /* PercentEqualsToken */, "<<=": 65 /* LessThanLessThanEqualsToken */, ">>=": 66 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 68 /* AmpersandEqualsToken */, "|=": 69 /* BarEqualsToken */, "^=": 70 /* CaretEqualsToken */, "@": 57 /* AtToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -7227,9 +7176,9 @@ var ts; if (len >= 2 && len <= 11) { var ch = tokenValue.charCodeAt(0); if (ch >= 97 /* a */ && ch <= 122 /* z */) { - token = textToToken.get(tokenValue); - if (token !== undefined) { - return token; + var keyword = textToKeyword.get(tokenValue); + if (keyword !== undefined) { + return token = keyword; } } } @@ -7909,7 +7858,7 @@ var ts; pos++; } tokenValue = text.substring(tokenPos, pos); - return token = 71 /* Identifier */; + return token = getIdentifierToken(); } else { return token = 0 /* Unknown */; @@ -21423,7 +21372,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(281 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -21618,7 +21567,7 @@ var ts; nextJSDocToken(); } } - function skipWhitespaceOrAsterisk(next) { + function skipWhitespaceOrAsterisk() { if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range @@ -21632,7 +21581,7 @@ var ts; else if (token() === 39 /* AsteriskToken */) { precedingLineBreak = false; } - next(); + nextJSDocToken(); } } function parseTag(indent) { @@ -21640,9 +21589,8 @@ var ts; var atToken = createNode(57 /* AtToken */, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); - // Use 'nextToken' instead of 'nextJsDocToken' so we can parse a type like 'number' in `@enum number` - var tagName = parseJSDocIdentifierName(/*message*/ undefined, nextToken); - skipWhitespaceOrAsterisk(nextToken); + var tagName = parseJSDocIdentifierName(/*message*/ undefined); + skipWhitespaceOrAsterisk(); var tag; switch (tagName.escapedText) { case "augments": @@ -21779,7 +21727,7 @@ var ts; tagsEnd = tag.end; } function tryParseTypeExpression() { - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); return token() === 17 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { @@ -21813,7 +21761,7 @@ var ts; function parseParameterOrPropertyTag(atToken, tagName, target, indent) { var typeExpression = tryParseTypeExpression(); var isNameFirst = !typeExpression; - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed; skipWhitespace(); if (isNameFirst) { @@ -21932,7 +21880,7 @@ var ts; } function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); var typedefTag = createNode(302 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; @@ -22165,8 +22113,7 @@ var ts; } return entity; } - function parseJSDocIdentifierName(message, next) { - if (next === void 0) { next = nextJSDocToken; } + function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { return createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } @@ -22175,7 +22122,7 @@ var ts; var result = createNode(71 /* Identifier */, pos); result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); finishNode(result, end); - next(); + nextJSDocToken(); return result; } } @@ -23661,30 +23608,6 @@ var ts; type: "object" }, description: ts.Diagnostics.List_of_language_service_plugins - }, - // extra options - { - name: "accessorOptimization", - type: "boolean" - }, - { - // this option can only be specified in tsconfig.json - // use type = object to copy the value as-is - name: "defines", - type: "object", - isTSConfigOnly: true - }, - { - name: "emitReflection", - type: "boolean" - }, - { - name: "noEmitJs", - type: "boolean" - }, - { - name: "reorderFiles", - type: "boolean" } ]); /* @internal */ @@ -23876,7 +23799,7 @@ var ts; i++; break; case "list": - var result = parseListTypeOption(opt, args[i], errors); + var result = parseListTypeOption(opt, args[i], errors); // tslint:disable-line no-unnecessary-type-assertion options[opt.name] = result || []; if (result) { i++; @@ -23998,8 +23921,7 @@ var ts; } /* @internal */ function printVersion() { - ts.sys.write("Version : " + ts.version_plus + ts.sys.newLine); - ts.sys.write("typescript-version : " + ts.version + ts.sys.newLine); + ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + ts.sys.newLine); } ts.printVersion = printVersion; /* @internal */ @@ -24411,7 +24333,7 @@ var ts; return undefined; } else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); // tslint:disable-line no-unnecessary-type-assertion } else { return optionDefinition.type; @@ -24474,7 +24396,7 @@ var ts; case "object": return {}; default: - return option.type.keys().next().value; + return option.type.keys().next().value; // tslint:disable-line no-unnecessary-type-assertion } } function makePadding(paddingLength) { @@ -24954,7 +24876,7 @@ var ts; if (isNullOrUndefined(value)) return undefined; if (option.type === "list") { - var listOption_1 = option; + var listOption_1 = option; // tslint:disable-line no-unnecessary-type-assertion if (listOption_1.element.isFilePath || !ts.isString(listOption_1.element.type)) { return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return !!v; }); } @@ -25298,7 +25220,7 @@ var ts; case "boolean": return typeof value === "boolean" ? value : ""; case "list": - var elementType_1 = option.element; + var elementType_1 = option.element; // tslint:disable-line no-unnecessary-type-assertion return ts.isArray(value) ? value.map(function (v) { return getOptionValueWithEmptyStrings(v, elementType_1); }) : ""; default: return ts.forEachEntry(option.type, function (optionEnumValue, optionStringValue) { @@ -56136,7 +56058,8 @@ var ts; return true; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 - if (target && ts.getModifierFlags(node) & 1 /* Export */ && target.flags & 67220415 /* Value */) { + if (target && ts.getModifierFlags(node) & 1 /* Export */ && + target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -69094,7 +69017,6 @@ var ts; var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); - var typeChecker = context.getEmitHost().getTypeChecker(); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; @@ -70027,13 +69949,7 @@ var ts; statements.push(transformSemicolonClassElementToStatement(member)); break; case 154 /* MethodDeclaration */: - var method = member; - if (method.isJumpTarget || (method.original && method.original.isJumpTarget)) { - transformJumpTarget(statements, getClassMemberPrefix(node, member), member); - } - else { - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); - } + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -70051,30 +69967,6 @@ var ts; } } } - function transformJumpTarget(statements, receiver, member) { - var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); - statements.push(ts.createStatement(ts.createAssignment(memberName, member.name))); - var sourceMapRange = ts.getSourceMapRange(member); - var memberFunction = transformMethodToFunctionDeclaration(member, /*location*/ member, /*name*/ member.name); - ts.setEmitFlags(memberFunction, 1536 /* NoComments */); - ts.setSourceMapRange(memberFunction, sourceMapRange); - statements.push(memberFunction); - } - function transformMethodToFunctionDeclaration(node, location, name) { - var savedConvertedLoopState = convertedLoopState; - convertedLoopState = undefined; - var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); - var parameters = ts.visitParameterList(node.parameters, visitor, context); - var body = transformFunctionBody(node); - exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); - convertedLoopState = savedConvertedLoopState; - return ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, node.asteriskToken, name, - /*typeParameters*/ undefined, parameters, - /*type*/ undefined, body), location), - /*original*/ node); - } /** * Transforms a SemicolonClassElement into a statement for a class body function. * @@ -70142,14 +70034,18 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterExpression = createAccessorExpression(getAccessor, firstAccessor, receiver, container); - var getter = ts.createPropertyAssignment("get", getterExpression); + var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); + ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); + ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); + var getter = ts.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); } if (setAccessor) { - var setterExpression = createAccessorExpression(setAccessor, firstAccessor, receiver, container); - var setter = ts.createPropertyAssignment("set", setterExpression); + var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); + ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); + ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); + var setter = ts.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } @@ -70167,75 +70063,6 @@ var ts; return call; } /** - * If the accessor method contains only one call to another method, use that method to define the accessor directly. - */ - function createAccessorExpression(accessor, firstAccessor, receiver, container) { - var expression; - var method = compilerOptions.accessorOptimization ? getJumpTargetOfAccessor(accessor) : null; - if (method) { - var methodName = ts.getMutableClone(method.name); - ts.setEmitFlags(methodName, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); - ts.setSourceMapRange(methodName, method.name); - if (firstAccessor.pos > method.pos) { // the target method has been already emitted. - var target = ts.getMutableClone(receiver); - ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); - ts.setSourceMapRange(target, firstAccessor.name); - expression = ts.createPropertyAccess(target, methodName); - } - else { - expression = methodName; - method.isJumpTarget = true; - } - } - else { - expression = transformFunctionLikeToExpression(accessor, /*location*/ undefined, /*name*/ undefined, container); - } - ts.setSourceMapRange(expression, ts.getSourceMapRange(accessor)); - ts.setEmitFlags(expression, 512 /* NoLeadingComments */); - return expression; - } - function getJumpTargetOfAccessor(accessor) { - if (accessor.body.statements.length != 1) { - return undefined; - } - var statement = accessor.body.statements[0]; - if (statement.kind !== 219 /* ExpressionStatement */ && - statement.kind !== 228 /* ReturnStatement */) { - return undefined; - } - var expression = statement.expression; - if (expression.kind !== 189 /* CallExpression */) { - return undefined; - } - var callExpression = expression; - if (accessor.kind === 157 /* SetAccessor */) { - if (callExpression.arguments.length != 1) { - return undefined; - } - var argument = callExpression.arguments[0]; - if (argument.kind !== 71 /* Identifier */) { - return undefined; - } - } - else { - if (callExpression.arguments.length != 0) { - return undefined; - } - } - if (callExpression.expression.kind !== 187 /* PropertyAccessExpression */) { - return undefined; - } - var propertyExpression = callExpression.expression; - if (propertyExpression.expression.kind !== 99 /* ThisKeyword */) { - return undefined; - } - var symbol = typeChecker.getSymbolAtLocation(propertyExpression.name); - if (!symbol) { - return undefined; - } - return ts.getDeclarationOfKind(symbol, 154 /* MethodDeclaration */); - } - /** * Visits an ArrowFunction and transforms it into a FunctionExpression. * * @param node An ArrowFunction node. @@ -79333,9 +79160,6 @@ var ts; var moduleKind = ts.getEmitModuleKind(compilerOptions); var transformers = []; ts.addRange(transformers, customTransformers && customTransformers.before); - if (compilerOptions.defines || compilerOptions.emitReflection) { - transformers.push(ts.transformTypeScriptPlus); - } transformers.push(ts.transformTypeScript); if (jsx === 2 /* React */) { transformers.push(ts.transformJsx); @@ -79632,976 +79456,6 @@ var ts; } ts.transformNodes = transformNodes; })(ts || (ts = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// The MIT License (MIT) -// -// Copyright (c) 2015-present, Dom Chen. -// All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in the -// Software without restriction, including without limitation the rights to use, copy, -// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, -// and to permit persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -////////////////////////////////////////////////////////////////////////////////////// -/*@internal*/ -var ts; -(function (ts) { - function transformTypeScriptPlus(context) { - var compilerOptions = context.getCompilerOptions(); - var compilerDefines = getCompilerDefines(compilerOptions.defines); - var typeChecker = compilerOptions.emitReflection || compilerDefines ? context.getEmitHost().getTypeChecker() : null; - var previousOnSubstituteNode = context.onSubstituteNode; - if (compilerDefines) { - context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(71 /* Identifier */); - } - return ts.chainBundle(transformSourceFile); - function transformSourceFile(node) { - if (!compilerOptions.emitReflection) { - return node; - } - var visited = ts.updateSourceFileNode(node, ts.visitNodes(node.statements, visitStatement, ts.isStatement)); - ts.addEmitHelpers(visited, context.readEmitHelpers()); - return visited; - } - function visitStatement(node) { - if (ts.hasModifier(node, 2 /* Ambient */)) { - return node; - } - if (node.kind === 238 /* ClassDeclaration */) { - return visitClassDeclaration(node); - } - if (node.kind === 242 /* ModuleDeclaration */) { - return visitModule(node); - } - return node; - } - function visitModule(node) { - if (node.body.kind === 242 /* ModuleDeclaration */) { - return updateModuleDeclaration(node, visitModule(node.body)); - } - if (node.body.kind === 243 /* ModuleBlock */) { - var body = updateModuleBlock(node.body, ts.visitNodes(node.body.statements, visitStatement, ts.isStatement)); - return updateModuleDeclaration(node, body); - } - return node; - } - function updateModuleDeclaration(node, body) { - if (node.body !== body) { - var updated = ts.getMutableClone(node); - updated.body = body; - return ts.updateNode(updated, node); - } - return node; - } - function updateModuleBlock(node, statements) { - if (node.statements !== statements) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements); - return ts.updateNode(updated, node); - } - return node; - } - function visitClassDeclaration(node) { - var classStatement = ts.getMutableClone(node); - var statements = [classStatement]; - var interfaceMap = {}; - getImplementedInterfaces(node, interfaceMap); - var allInterfaces = Object.keys(interfaceMap); - var interfaces; - var superTypes = getSuperClassTypes(node); - if (superTypes) { - interfaces = []; - for (var _i = 0, allInterfaces_1 = allInterfaces; _i < allInterfaces_1.length; _i++) { - var type = allInterfaces_1[_i]; - if (superTypes.indexOf(type) === -1) { - interfaces.push(type); - } - } - } - else { - interfaces = allInterfaces; - } - node.typeNames = interfaces; - var fullClassName = typeChecker.getFullyQualifiedName(node.symbol); - var expression = createReflectHelper(context, node.name, fullClassName, interfaces); - ts.setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); - var statement = ts.createStatement(expression); - ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); - statements.push(statement); - return statements; - } - function getImplementedInterfaces(node, result) { - var superInterfaces = undefined; - if (node.kind === 238 /* ClassDeclaration */) { - superInterfaces = ts.getClassImplementsHeritageClauseElements(node); - } - else { - superInterfaces = ts.getInterfaceBaseTypeNodes(node); - } - if (superInterfaces) { - superInterfaces.forEach(function (superInterface) { - var type = typeChecker.getTypeAtLocation(superInterface); - if (type && type.symbol && type.symbol.flags & 64 /* Interface */) { - var symbol = type.symbol; - var fullName = typeChecker.getFullyQualifiedName(symbol); - result[fullName] = true; - var declaration = ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); - if (declaration) { - getImplementedInterfaces(declaration, result); - } - } - }); - } - } - function getSuperClassTypes(node) { - var superClass = ts.getClassExtendsHeritageElement(node); - if (!superClass) { - return undefined; - } - var type = typeChecker.getTypeAtLocation(superClass); - if (!type || !type.symbol) { - return undefined; - } - var declaration = ts.getDeclarationOfKind(type.symbol, 238 /* ClassDeclaration */); - return declaration ? declaration.typeNames : undefined; - } - function getCompilerDefines(defines) { - if (!defines) { - return null; - } - var compilerDefines = {}; - var keys = Object.keys(defines); - for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { - var key = keys_1[_i]; - var value = defines[key]; - var type = typeof value; - switch (type) { - case "boolean": - case "number": - compilerDefines[key] = value.toString(); - break; - case "string": - compilerDefines[key] = "\"" + value + "\""; - break; - } - } - if (Object.keys(compilerDefines).length == 0) { - return null; - } - return compilerDefines; - } - function isDefinedConstant(node) { - var nodeText = ts.getTextOfIdentifierOrLiteral(node); - if (compilerDefines[nodeText] === undefined) { - return false; - } - if (!node.parent) { - return false; - } - if (node.parent.kind === 235 /* VariableDeclaration */ && node.parent.name === node) { - return false; - } - if (node.parent.kind === 202 /* BinaryExpression */) { - var parent = node.parent; - if (parent.left === node && parent.operatorToken.kind === 58 /* EqualsToken */) { - return false; - } - } - var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol || !symbol.declarations) { - return false; - } - var declaration = symbol.declarations[0]; - if (!declaration) { - return false; - } - if (declaration.kind !== 235 /* VariableDeclaration */) { - return false; - } - var statement = declaration.parent.parent; - return (statement.parent.kind === 277 /* SourceFile */); - } - /** - * Hooks node substitutions. - * @param emitContext The context for the emitter. - * @param node The node to substitute. - */ - function onSubstituteNode(hint, node) { - node = previousOnSubstituteNode(hint, node); - if (ts.isIdentifier(node) && isDefinedConstant(node)) { - var nodeText = ts.getTextOfIdentifierOrLiteral(node); - return ts.createIdentifier(compilerDefines[nodeText]); - } - return node; - } - } - ts.transformTypeScriptPlus = transformTypeScriptPlus; - var reflectHelper = { - name: "typescript:reflect", - scoped: false, - priority: 0, - text: "\n var __reflect = (this && this.__reflect) || function (p, c, t) {\n p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;\n };" - }; - function createReflectHelper(context, name, fullClassName, interfaces) { - context.requestEmitHelper(reflectHelper); - var argumentsArray = [ - ts.createPropertyAccess(name, ts.createIdentifier("prototype")), - ts.createLiteral(fullClassName) - ]; - if (interfaces.length) { - var elements = []; - for (var _i = 0, interfaces_1 = interfaces; _i < interfaces_1.length; _i++) { - var value = interfaces_1[_i]; - elements.push(ts.createLiteral(value)); - } - argumentsArray.push(ts.createArrayLiteral(elements)); - } - return ts.createCall(ts.getHelperName("__reflect"), - /*typeArguments*/ undefined, argumentsArray); - } -})(ts || (ts = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// The MIT License (MIT) -// -// Copyright (c) 2015-present, Dom Chen. -// All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in the -// Software without restriction, including without limitation the rights to use, copy, -// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, -// and to permit persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -////////////////////////////////////////////////////////////////////////////////////// -var ts; -(function (ts) { - var checker; - var sourceFiles; - var rootFileNames; - var dependencyMap; - var pathWeightMap; - var visitedBlocks; - var calledMethods = []; - function createMap() { - var map = Object.create(null); - // Using 'delete' on an object causes V8 to put the object in dictionary mode. - // This disables creation of hidden classes, which are expensive when an object is - // constantly changing shape. - map["__"] = undefined; - delete map["__"]; - return map; - } - function reorderSourceFiles(program) { - sourceFiles = program.getSourceFiles(); - rootFileNames = program.getRootFileNames(); - checker = program.getTypeChecker(); - visitedBlocks = []; - buildDependencyMap(); - var result = sortOnDependency(); - sourceFiles = []; - rootFileNames = []; - checker = null; - dependencyMap = null; - visitedBlocks = []; - return result; - } - ts.reorderSourceFiles = reorderSourceFiles; - function addDependency(file, dependent) { - if (file == dependent) { - return; - } - var list = dependencyMap[file]; - if (!list) { - list = dependencyMap[file] = []; - } - if (list.indexOf(dependent) == -1) { - list.push(dependent); - } - } - function buildDependencyMap() { - dependencyMap = createMap(); - for (var i = 0; i < sourceFiles.length; i++) { - var sourceFile = sourceFiles[i]; - if (sourceFile.isDeclarationFile) { - continue; - } - visitFile(sourceFile); - } - } - function visitFile(sourceFile) { - var statements = sourceFile.statements; - var length = statements.length; - for (var i = 0; i < length; i++) { - var statement = statements[i]; - if (ts.hasModifier(statement, 2 /* Ambient */)) { // has the 'declare' keyword - continue; - } - visitStatement(statements[i]); - } - } - function visitStatement(statement) { - if (!statement) { - return; - } - switch (statement.kind) { - case 219 /* ExpressionStatement */: - var expression = statement; - visitExpression(expression.expression); - break; - case 238 /* ClassDeclaration */: - checkInheriting(statement); - visitStaticMember(statement); - if (statement.transformFlags & 4096 /* ContainsDecorators */) { - visitClassDecorators(statement); - } - break; - case 217 /* VariableStatement */: - visitVariableList(statement.declarationList); - break; - case 246 /* ImportEqualsDeclaration */: - var importDeclaration = statement; - checkDependencyAtLocation(importDeclaration.moduleReference); - break; - case 242 /* ModuleDeclaration */: - visitModule(statement); - break; - case 216 /* Block */: - visitBlock(statement); - break; - case 220 /* IfStatement */: - var ifStatement = statement; - visitExpression(ifStatement.expression); - visitStatement(ifStatement.thenStatement); - visitStatement(ifStatement.elseStatement); - break; - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - var doStatement = statement; - visitExpression(doStatement.expression); - visitStatement(doStatement.statement); - break; - case 223 /* ForStatement */: - var forStatement = statement; - visitExpression(forStatement.condition); - visitExpression(forStatement.incrementor); - if (forStatement.initializer) { - if (forStatement.initializer.kind === 236 /* VariableDeclarationList */) { - visitVariableList(forStatement.initializer); - } - else { - visitExpression(forStatement.initializer); - } - } - break; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - var forInStatement = statement; - visitExpression(forInStatement.expression); - if (forInStatement.initializer) { - if (forInStatement.initializer.kind === 236 /* VariableDeclarationList */) { - visitVariableList(forInStatement.initializer); - } - else { - visitExpression(forInStatement.initializer); - } - } - break; - case 228 /* ReturnStatement */: - visitExpression(statement.expression); - break; - case 230 /* SwitchStatement */: - var switchStatment = statement; - visitExpression(switchStatment.expression); - switchStatment.caseBlock.clauses.forEach(function (element) { - if (element.kind === 269 /* CaseClause */) { - visitExpression(element.expression); - } - element.statements.forEach(function (element) { - visitStatement(element); - }); - }); - break; - case 231 /* LabeledStatement */: - visitStatement(statement.statement); - break; - case 232 /* ThrowStatement */: - visitExpression(statement.expression); - break; - case 233 /* TryStatement */: - var tryStatement = statement; - visitBlock(tryStatement.tryBlock); - visitBlock(tryStatement.finallyBlock); - if (tryStatement.catchClause) { - visitBlock(tryStatement.catchClause.block); - } - break; - } - } - function visitModule(node) { - if (node.body.kind === 242 /* ModuleDeclaration */) { - visitModule(node.body); - return; - } - if (node.body.kind === 243 /* ModuleBlock */) { - for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (ts.hasModifier(statement, 2 /* Ambient */)) { // has the 'declare' keyword - continue; - } - visitStatement(statement); - } - } - } - function checkDependencyAtLocation(node) { - var symbol = checker.getSymbolAtLocation(node); - if (!symbol || !symbol.declarations) { - return; - } - var sourceFile = getSourceFileOfNode(symbol.declarations[0]); - if (!sourceFile || sourceFile.isDeclarationFile) { - return; - } - addDependency(getSourceFileOfNode(node).fileName, sourceFile.fileName); - } - function checkInheriting(node) { - if (!node.heritageClauses) { - return; - } - var heritageClause = null; - for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { - var clause = _a[_i]; - if (clause.token === 85 /* ExtendsKeyword */) { - heritageClause = clause; - break; - } - } - if (!heritageClause) { - return; - } - var superClasses = heritageClause.types; - if (!superClasses) { - return; - } - superClasses.forEach(function (superClass) { - checkDependencyAtLocation(superClass.expression); - }); - } - function visitStaticMember(node) { - var members = node.members; - if (!members) { - return; - } - for (var _i = 0, members_6 = members; _i < members_6.length; _i++) { - var member = members_6[_i]; - if (!ts.hasModifier(member, 32 /* Static */)) { - continue; - } - if (member.kind == 152 /* PropertyDeclaration */) { - var property = member; - visitExpression(property.initializer); - } - } - } - function visitClassDecorators(node) { - if (node.decorators) { - visitDecorators(node.decorators); - } - var members = node.members; - if (!members) { - return; - } - for (var _i = 0, members_7 = members; _i < members_7.length; _i++) { - var member = members_7[_i]; - var decorators = void 0; - var functionLikeMember = void 0; - if (member.kind === 156 /* GetAccessor */ || member.kind === 157 /* SetAccessor */) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member !== accessors.firstAccessor) { - continue; - } - decorators = accessors.firstAccessor.decorators; - if (!decorators && accessors.secondAccessor) { - decorators = accessors.secondAccessor.decorators; - } - functionLikeMember = accessors.setAccessor; - } - else { - decorators = member.decorators; - if (member.kind === 154 /* MethodDeclaration */) { - functionLikeMember = member; - } - } - if (decorators) { - visitDecorators(decorators); - } - if (functionLikeMember) { - for (var _a = 0, _b = functionLikeMember.parameters; _a < _b.length; _a++) { - var parameter = _b[_a]; - if (parameter.decorators) { - visitDecorators(parameter.decorators); - } - } - } - } - } - function visitDecorators(decorators) { - for (var _i = 0, decorators_2 = decorators; _i < decorators_2.length; _i++) { - var decorator = decorators_2[_i]; - visitCallExpression(decorator.expression); - } - } - function visitExpression(expression) { - if (!expression) { - return; - } - switch (expression.kind) { - case 190 /* NewExpression */: - case 189 /* CallExpression */: - visitCallArguments(expression); - visitCallExpression(expression.expression); - break; - case 71 /* Identifier */: - checkDependencyAtLocation(expression); - break; - case 187 /* PropertyAccessExpression */: - checkDependencyAtLocation(expression); - break; - case 188 /* ElementAccessExpression */: - visitExpression(expression.expression); - break; - case 186 /* ObjectLiteralExpression */: - visitObjectLiteralExpression(expression); - break; - case 185 /* ArrayLiteralExpression */: - var arrayLiteral = expression; - arrayLiteral.elements.forEach(visitExpression); - break; - case 204 /* TemplateExpression */: - var template = expression; - template.templateSpans.forEach(function (span) { - visitExpression(span.expression); - }); - break; - case 193 /* ParenthesizedExpression */: - var parenthesized = expression; - visitExpression(parenthesized.expression); - break; - case 202 /* BinaryExpression */: - visitBinaryExpression(expression); - break; - case 201 /* PostfixUnaryExpression */: - case 200 /* PrefixUnaryExpression */: - visitExpression(expression.operand); - break; - case 196 /* DeleteExpression */: - visitExpression(expression.expression); - break; - case 191 /* TaggedTemplateExpression */: - visitExpression(expression.tag); - visitExpression(expression.template); - break; - case 203 /* ConditionalExpression */: - visitExpression(expression.condition); - visitExpression(expression.whenTrue); - visitExpression(expression.whenFalse); - break; - case 206 /* SpreadElement */: - visitExpression(expression.expression); - break; - case 198 /* VoidExpression */: - visitExpression(expression.expression); - break; - case 205 /* YieldExpression */: - visitExpression(expression.expression); - break; - case 199 /* AwaitExpression */: - visitExpression(expression.expression); - break; - case 197 /* TypeOfExpression */: - visitExpression(expression.expression); - break; - case 211 /* NonNullExpression */: - visitExpression(expression.expression); - break; - case 192 /* TypeAssertionExpression */: - visitExpression(expression.expression); - break; - } - // FunctionExpression - // ArrowFunction - // ClassExpression - // OmittedExpression - // ExpressionWithTypeArguments - // AsExpression - } - function visitBinaryExpression(binary) { - var left = binary.left; - var right = binary.right; - visitExpression(left); - visitExpression(right); - if (binary.operatorToken.kind === 58 /* EqualsToken */ && - (left.kind === 71 /* Identifier */ || left.kind === 187 /* PropertyAccessExpression */) && - (right.kind === 71 /* Identifier */ || right.kind === 187 /* PropertyAccessExpression */)) { - var symbol = checker.getSymbolAtLocation(left); - if (!symbol || !symbol.declarations) { - return; - } - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 235 /* VariableDeclaration */ || declaration.kind === 152 /* PropertyDeclaration */) { - var variable = declaration; - if (variable.initializer) { - continue; - } - if (!variable.delayInitializerList) { - variable.delayInitializerList = []; - } - variable.delayInitializerList.push(right); - if (variable.callerList) { - for (var _b = 0, _c = variable.callerList; _b < _c.length; _b++) { - var callerFileName = _c[_b]; - checkCallTarget(callerFileName, right); - } - } - } - } - } - } - function visitObjectLiteralExpression(objectLiteral) { - objectLiteral.properties.forEach(function (element) { - switch (element.kind) { - case 273 /* PropertyAssignment */: - visitExpression(element.initializer); - break; - case 274 /* ShorthandPropertyAssignment */: - visitExpression(element.objectAssignmentInitializer); - break; - case 275 /* SpreadAssignment */: - visitExpression(element.expression); - break; - } - }); - } - function visitCallArguments(callExpression) { - if (callExpression.arguments) { - callExpression.arguments.forEach(function (argument) { - visitExpression(argument); - }); - } - } - function visitCallExpression(expression) { - expression = escapeParenthesized(expression); - visitExpression(expression); - switch (expression.kind) { - case 194 /* FunctionExpression */: - var functionExpression = expression; - visitBlock(functionExpression.body); - break; - case 187 /* PropertyAccessExpression */: - case 71 /* Identifier */: - var callerFileName = getSourceFileOfNode(expression).fileName; - checkCallTarget(callerFileName, expression); - break; - case 189 /* CallExpression */: - visitReturnedFunction(expression.expression); - break; - } - } - function visitReturnedFunction(expression) { - expression = escapeParenthesized(expression); - var returnExpressions = []; - if (expression.kind === 189 /* CallExpression */) { - var expressions = visitReturnedFunction(expression.expression); - for (var _i = 0, expressions_2 = expressions; _i < expressions_2.length; _i++) { - var returnExpression = expressions_2[_i]; - var returns = visitReturnedFunction(returnExpression); - returnExpressions = returnExpressions.concat(returns); - } - return returnExpressions; - } - var functionBlocks = []; - switch (expression.kind) { - case 194 /* FunctionExpression */: - functionBlocks.push(expression.body); - break; - case 187 /* PropertyAccessExpression */: - case 71 /* Identifier */: - var callerFileName = getSourceFileOfNode(expression).fileName; - var declarations = []; - getForwardDeclarations(expression, declarations, callerFileName); - for (var _a = 0, declarations_11 = declarations; _a < declarations_11.length; _a++) { - var declaration = declarations_11[_a]; - var sourceFile = getSourceFileOfNode(declaration); - if (!sourceFile || sourceFile.isDeclarationFile) { - continue; - } - if (declaration.kind === 237 /* FunctionDeclaration */ || - declaration.kind === 154 /* MethodDeclaration */) { - functionBlocks.push(declaration.body); - } - } - break; - } - for (var _b = 0, functionBlocks_1 = functionBlocks; _b < functionBlocks_1.length; _b++) { - var block = functionBlocks_1[_b]; - for (var _c = 0, _d = block.statements; _c < _d.length; _c++) { - var statement = _d[_c]; - if (statement.kind === 228 /* ReturnStatement */) { - var returnExpression = statement.expression; - returnExpressions.push(returnExpression); - visitCallExpression(returnExpression); - } - } - } - return returnExpressions; - } - function escapeParenthesized(expression) { - if (expression.kind === 193 /* ParenthesizedExpression */) { - return escapeParenthesized(expression.expression); - } - return expression; - } - function checkCallTarget(callerFileName, target) { - var declarations = []; - getForwardDeclarations(target, declarations, callerFileName); - for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { - var declaration = declarations_12[_i]; - var sourceFile = getSourceFileOfNode(declaration); - if (!sourceFile || sourceFile.isDeclarationFile) { - continue; - } - addDependency(callerFileName, sourceFile.fileName); - if (declaration.kind === 237 /* FunctionDeclaration */) { - visitBlock(declaration.body); - } - else if (declaration.kind === 154 /* MethodDeclaration */) { - visitBlock(declaration.body); - calledMethods.push(declaration); - } - else if (declaration.kind === 238 /* ClassDeclaration */) { - checkClassInstantiation(declaration); - } - } - } - function getForwardDeclarations(reference, declarations, callerFileName) { - var symbol = checker.getSymbolAtLocation(reference); - if (!symbol || !symbol.declarations) { - return; - } - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - switch (declaration.kind) { - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 238 /* ClassDeclaration */: - if (declarations.indexOf(declaration) == -1) { - declarations.push(declaration); - } - break; - case 246 /* ImportEqualsDeclaration */: - getForwardDeclarations(declaration.moduleReference, declarations, callerFileName); - break; - case 235 /* VariableDeclaration */: - case 152 /* PropertyDeclaration */: - var variable = declaration; - var initializer = variable.initializer; - if (initializer) { - if (initializer.kind === 71 /* Identifier */ || initializer.kind === 187 /* PropertyAccessExpression */) { - getForwardDeclarations(initializer, declarations, callerFileName); - } - } - else { - if (variable.delayInitializerList) { - for (var _b = 0, _c = variable.delayInitializerList; _b < _c.length; _b++) { - var expression = _c[_b]; - getForwardDeclarations(expression, declarations, callerFileName); - } - } - if (variable.callerList) { - if (variable.callerList.indexOf(callerFileName) == -1) { - variable.callerList.push(callerFileName); - } - } - else { - variable.callerList = [callerFileName]; - } - } - break; - } - } - } - function checkClassInstantiation(node) { - var methodNames = []; - var superClass = ts.getClassExtendsHeritageElement(node); - if (superClass) { - var type = checker.getTypeAtLocation(superClass); - if (type && type.symbol) { - var declaration = ts.getDeclarationOfKind(type.symbol, 238 /* ClassDeclaration */); - if (declaration) { - methodNames = checkClassInstantiation(declaration); - } - } - } - var members = node.members; - if (!members) { - return []; - } - var index = calledMethods.length; - for (var _i = 0, members_8 = members; _i < members_8.length; _i++) { - var member = members_8[_i]; - if (ts.hasModifier(member, 32 /* Static */)) { - continue; - } - if (member.kind === 154 /* MethodDeclaration */) { // called by super class. - var methodName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name)); - if (methodNames.indexOf(methodName) != -1) { - visitBlock(member.body); - } - } - if (member.kind === 152 /* PropertyDeclaration */) { - var property = member; - visitExpression(property.initializer); - } - else if (member.kind === 155 /* Constructor */) { - var constructor = member; - visitBlock(constructor.body); - } - } - for (var i = index; i < calledMethods.length; i++) { - var method = calledMethods[i]; - for (var _a = 0, members_9 = members; _a < members_9.length; _a++) { - var memeber = members_9[_a]; - if (memeber === method) { - var methodName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(method.name)); - methodNames.push(methodName); - } - } - } - if (index == 0) { - calledMethods.length = 0; - } - return methodNames; - } - function visitBlock(block) { - if (!block || visitedBlocks.indexOf(block) != -1) { - return; - } - visitedBlocks.push(block); - for (var _i = 0, _a = block.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - visitStatement(statement); - } - visitedBlocks.pop(); - } - function visitVariableList(variables) { - if (!variables) { - return; - } - variables.declarations.forEach(function (declaration) { - visitExpression(declaration.initializer); - }); - } - function sortOnDependency() { - var result = {}; - result.sortedFileNames = []; - result.circularReferences = []; - pathWeightMap = createMap(); - var dtsFiles = []; - var tsFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var path = sourceFile.fileName; - if (sourceFile.isDeclarationFile) { - pathWeightMap[path] = 10000; - dtsFiles.push(sourceFile); - continue; - } - var references = updatePathWeight(path, 0, [path]); - if (references.length > 0) { - result.circularReferences = references; - break; - } - tsFiles.push(sourceFile); - } - if (result.circularReferences.length === 0) { - tsFiles.sort(function (a, b) { - return pathWeightMap[b.fileName] - pathWeightMap[a.fileName]; - }); - sourceFiles.length = 0; - rootFileNames.length = 0; - dtsFiles.concat(tsFiles).forEach(function (sourceFile) { - sourceFiles.push(sourceFile); - rootFileNames.push(sourceFile.fileName); - result.sortedFileNames.push(sourceFile.fileName); - }); - } - pathWeightMap = null; - return result; - } - function updatePathWeight(path, weight, references) { - if (pathWeightMap[path] === undefined) { - pathWeightMap[path] = weight; - } - else { - if (pathWeightMap[path] < weight) { - pathWeightMap[path] = weight; - } - else { - return []; - } - } - var list = dependencyMap[path]; - if (!list) { - return []; - } - for (var _i = 0, list_3 = list; _i < list_3.length; _i++) { - var parentPath = list_3[_i]; - if (references.indexOf(parentPath) != -1) { - references.push(parentPath); - return references; - } - var result = updatePathWeight(parentPath, weight + 1, references.concat(parentPath)); - if (result.length > 0) { - return result; - } - } - return []; - } - function getSourceFileOfNode(node) { - while (node && node.kind !== 277 /* SourceFile */) { - node = node.parent; - } - return node; - } -})(ts || (ts = {})); /* @internal */ var ts; (function (ts) { @@ -81445,8 +80299,8 @@ var ts; } } else { - for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { - var sourceFile = sourceFiles_2[_a]; + for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { + var sourceFile = sourceFiles_1[_a]; var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); if (result) { return result; @@ -86117,7 +84971,7 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - 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, getTypeChecker: program.getTypeChecker, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + 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, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches var path = toPath(f); if (getSourceFileByPath(path)) @@ -87063,8 +85917,8 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var sourceFile = sourceFiles_2[_i]; if (!sourceFile.isDeclarationFile) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -97750,8 +96604,8 @@ var ts; function findModuleReferences(program, sourceFiles, searchModuleSymbol) { var refs = []; var checker = program.getTypeChecker(); - for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { - var referencingFile = sourceFiles_4[_i]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var referencingFile = sourceFiles_3[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; if (searchSourceFile.kind === 277 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { @@ -97781,8 +96635,8 @@ var ts; /** Returns a map from a module symbol Id to all import statements that directly reference the module. */ function getDirectImportsMap(sourceFiles, checker, cancellationToken) { var map = ts.createMap(); - for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { - var sourceFile = sourceFiles_5[_i]; + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); forEachImport(sourceFile, function (importDecl, moduleSpecifier) { @@ -98714,8 +97568,8 @@ var ts; return undefined; } var scope; - for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { - var declaration = declarations_13[_i]; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; var container = ts.getContainerNode(declaration); if (scope && scope !== container) { // Different declarations have different containers, bail out @@ -98764,8 +97618,8 @@ var ts; if (!signature.name || !ts.isIdentifier(signature.name)) return; var symbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(signature.name)); - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var sourceFile = sourceFiles_6[_i]; + for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { + var sourceFile = sourceFiles_5[_i]; for (var _a = 0, _b = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _a < _b.length; _a++) { var name = _b[_a]; if (!ts.isIdentifier(name) || name === signature.name || name.escapedText !== signature.name.escapedText) @@ -99430,8 +98284,8 @@ var ts; // To achieve that we will keep iterating until the result stabilizes. // Remember the last meaning lastIterationMeaning = meaning; - for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { - var declaration = declarations_14[_i]; + for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { + var declaration = declarations_12[_i]; var declarationMeaning = ts.getMeaningFromDeclaration(declaration); if (declarationMeaning & meaning) { meaning |= declarationMeaning; @@ -99554,7 +98408,7 @@ var ts; case "compilerOptions": forEachProperty(property.initializer, function (property, propertyName) { var option = ts.getOptionFromName(propertyName); - if (option && (option.isFilePath || option.type === "list" && option.element.isFilePath)) { + if (option && (option.isFilePath || option.type === "list" && option.element.isFilePath)) { // tslint:disable-line no-unnecessary-type-assertion updatePaths(property); } else if (propertyName === "paths") { @@ -100421,8 +99275,8 @@ var ts; }); }; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var sourceFile = sourceFiles_6[_i]; _loop_12(sourceFile); } rawItems.sort(compareNavigateToItems); @@ -100436,8 +99290,8 @@ var ts; if (!match) { return; // continue to next named declarations } - for (var _i = 0, declarations_15 = declarations; _i < declarations_15.length; _i++) { - var declaration = declarations_15[_i]; + for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { + var declaration = declarations_13[_i]; if (!shouldKeepItem(declaration, checker)) continue; if (patternMatcher.patternContainsDots) { @@ -111703,7 +110557,7 @@ var ts; return checker.createArrayType(recur(usageContext.numberIndexContext)); } else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { - var members_10 = ts.createUnderscoreEscapedMap(); + var members_6 = ts.createUnderscoreEscapedMap(); var callSignatures = []; var constructSignatures = []; var stringIndexInfo = void 0; @@ -111711,7 +110565,7 @@ var ts; usageContext.properties.forEach(function (context, name) { var symbol = checker.createSymbol(4 /* Property */, name); symbol.type = recur(context); - members_10.set(name, symbol); + members_6.set(name, symbol); }); } if (usageContext.callContexts) { @@ -111729,7 +110583,7 @@ var ts; if (usageContext.stringIndexContext) { stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); } - return checker.createAnonymousType(/*symbol*/ undefined, members_10, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 + return checker.createAnonymousType(/*symbol*/ undefined, members_6, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 } else { return undefined; @@ -113708,8 +112562,8 @@ var ts; ts.Debug.assert(members.length > 0); // There must be at least one child, since we extracted from one. var prevMember; var allProperties = true; - for (var _i = 0, members_11 = members; _i < members_11.length; _i++) { - var member = members_11[_i]; + for (var _i = 0, members_7 = members; _i < members_7.length; _i++) { + var member = members_7[_i]; if (member.pos > maxPos) { return prevMember || members[0]; } @@ -115495,8 +114349,8 @@ var ts; return ts.emptyArray; var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations); if (doc.length === 0 || declarations.some(hasJSDocInheritDocTag)) { - for (var _i = 0, declarations_16 = declarations; _i < declarations_16.length; _i++) { - var declaration = declarations_16[_i]; + for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { + var declaration = declarations_14[_i]; var inheritedDocs = findInheritedJSDocComments(declaration, declaration.symbol.name, checker); // TODO: GH#18217 // TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs if (inheritedDocs) @@ -116183,11 +115037,7 @@ var ts; /// Diagnostics function getSyntacticDiagnostics(fileName) { synchronizeHostData(); - var targetSourceFile; - if (fileName) { - targetSourceFile = getValidSourceFile(fileName); - } - return program.getSyntacticDiagnostics(targetSourceFile, cancellationToken).slice(); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken).slice(); } /** * getSemanticDiagnostics return array of Diagnostics. If '-d' is not enabled, only report semantic errors @@ -116195,10 +115045,7 @@ var ts; */ function getSemanticDiagnostics(fileName) { synchronizeHostData(); - var targetSourceFile; - if (fileName) { - targetSourceFile = getValidSourceFile(fileName); - } + var targetSourceFile = getValidSourceFile(fileName); // Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file. // Therefore only get diagnostics for given file. var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); @@ -116360,10 +115207,7 @@ var ts; function getEmitOutput(fileName, emitOnlyDtsFiles) { if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } synchronizeHostData(); - var sourceFile; - if (fileName) { - sourceFile = getValidSourceFile(fileName); - } + var sourceFile = getValidSourceFile(fileName); var customTransformers = host.getCustomTransformers && host.getCustomTransformers(); return ts.getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers); } diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 98764b3ae..8efaa85b4 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -17,7 +17,6 @@ declare namespace ts { const versionMajorMinor = "3.1"; /** The version of the TypeScript compiler release */ const version: string; - const version_plus = "3.1.5"; } declare namespace ts { /** @@ -70,7 +69,8 @@ declare namespace ts { pos: number; end: number; } - type JsDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.Unknown; + type JsDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.Unknown | KeywordSyntaxKind; + type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; enum SyntaxKind { Unknown = 0, @@ -692,7 +692,6 @@ declare namespace ts { parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; - isJumpTarget?: boolean; } interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; @@ -1333,7 +1332,6 @@ declare namespace ts { typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; - typeNames?: string[]; } interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.ClassDeclaration; @@ -2509,11 +2507,6 @@ declare namespace ts { /** Paths used to compute primary types search locations */ typeRoots?: string[]; esModuleInterop?: boolean; - accessorOptimization?: boolean; - defines?: MapLike; - emitReflection?: boolean; - noEmitJs?: boolean; - reorderFiles?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } interface TypeAcquisition { @@ -4147,13 +4140,6 @@ declare namespace ts { */ function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; } -declare namespace ts { - interface SortingResult { - sortedFileNames: string[]; - circularReferences: string[]; - } - function reorderSourceFiles(program: Program): SortingResult; -} declare namespace ts { function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 7367cd46a..c65793c16 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -75,8 +75,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.1"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".3"; - ts.version_plus = "3.1.5"; + ts.version = ts.versionMajorMinor + ".5"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -6082,6 +6081,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { return token >= 71 /* Identifier */; @@ -6092,136 +6092,85 @@ var ts; return token === 29 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; - var textToToken = ts.createMapFromTemplate({ - "abstract": 117 /* AbstractKeyword */, - "any": 119 /* AnyKeyword */, - "as": 118 /* AsKeyword */, - "boolean": 122 /* BooleanKeyword */, - "break": 72 /* BreakKeyword */, - "case": 73 /* CaseKeyword */, - "catch": 74 /* CatchKeyword */, - "class": 75 /* ClassKeyword */, - "continue": 77 /* ContinueKeyword */, - "const": 76 /* ConstKeyword */, - "constructor": 123 /* ConstructorKeyword */, - "debugger": 78 /* DebuggerKeyword */, - "declare": 124 /* DeclareKeyword */, - "default": 79 /* DefaultKeyword */, - "delete": 80 /* DeleteKeyword */, - "do": 81 /* DoKeyword */, - "else": 82 /* ElseKeyword */, - "enum": 83 /* EnumKeyword */, - "export": 84 /* ExportKeyword */, - "extends": 85 /* ExtendsKeyword */, - "false": 86 /* FalseKeyword */, - "finally": 87 /* FinallyKeyword */, - "for": 88 /* ForKeyword */, - "from": 143 /* FromKeyword */, - "function": 89 /* FunctionKeyword */, - "get": 125 /* GetKeyword */, - "if": 90 /* IfKeyword */, - "implements": 108 /* ImplementsKeyword */, - "import": 91 /* ImportKeyword */, - "in": 92 /* InKeyword */, - "infer": 126 /* InferKeyword */, - "instanceof": 93 /* InstanceOfKeyword */, - "interface": 109 /* InterfaceKeyword */, - "is": 127 /* IsKeyword */, - "keyof": 128 /* KeyOfKeyword */, - "let": 110 /* LetKeyword */, - "module": 129 /* ModuleKeyword */, - "namespace": 130 /* NamespaceKeyword */, - "never": 131 /* NeverKeyword */, - "new": 94 /* NewKeyword */, - "null": 95 /* NullKeyword */, - "number": 134 /* NumberKeyword */, - "object": 135 /* ObjectKeyword */, - "package": 111 /* PackageKeyword */, - "private": 112 /* PrivateKeyword */, - "protected": 113 /* ProtectedKeyword */, - "public": 114 /* PublicKeyword */, - "readonly": 132 /* ReadonlyKeyword */, - "require": 133 /* RequireKeyword */, - "global": 144 /* GlobalKeyword */, - "return": 96 /* ReturnKeyword */, - "set": 136 /* SetKeyword */, - "static": 115 /* StaticKeyword */, - "string": 137 /* StringKeyword */, - "super": 97 /* SuperKeyword */, - "switch": 98 /* SwitchKeyword */, - "symbol": 138 /* SymbolKeyword */, - "this": 99 /* ThisKeyword */, - "throw": 100 /* ThrowKeyword */, - "true": 101 /* TrueKeyword */, - "try": 102 /* TryKeyword */, - "type": 139 /* TypeKeyword */, - "typeof": 103 /* TypeOfKeyword */, - "undefined": 140 /* UndefinedKeyword */, - "unique": 141 /* UniqueKeyword */, - "unknown": 142 /* UnknownKeyword */, - "var": 104 /* VarKeyword */, - "void": 105 /* VoidKeyword */, - "while": 106 /* WhileKeyword */, - "with": 107 /* WithKeyword */, - "yield": 116 /* YieldKeyword */, - "async": 120 /* AsyncKeyword */, - "await": 121 /* AwaitKeyword */, - "of": 145 /* OfKeyword */, - "{": 17 /* OpenBraceToken */, - "}": 18 /* CloseBraceToken */, - "(": 19 /* OpenParenToken */, - ")": 20 /* CloseParenToken */, - "[": 21 /* OpenBracketToken */, - "]": 22 /* CloseBracketToken */, - ".": 23 /* DotToken */, - "...": 24 /* DotDotDotToken */, - ";": 25 /* SemicolonToken */, - ",": 26 /* CommaToken */, - "<": 27 /* LessThanToken */, - ">": 29 /* GreaterThanToken */, - "<=": 30 /* LessThanEqualsToken */, - ">=": 31 /* GreaterThanEqualsToken */, - "==": 32 /* EqualsEqualsToken */, - "!=": 33 /* ExclamationEqualsToken */, - "===": 34 /* EqualsEqualsEqualsToken */, - "!==": 35 /* ExclamationEqualsEqualsToken */, - "=>": 36 /* EqualsGreaterThanToken */, - "+": 37 /* PlusToken */, - "-": 38 /* MinusToken */, - "**": 40 /* AsteriskAsteriskToken */, - "*": 39 /* AsteriskToken */, - "/": 41 /* SlashToken */, - "%": 42 /* PercentToken */, - "++": 43 /* PlusPlusToken */, - "--": 44 /* MinusMinusToken */, - "<<": 45 /* LessThanLessThanToken */, - ">": 46 /* GreaterThanGreaterThanToken */, - ">>>": 47 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 48 /* AmpersandToken */, - "|": 49 /* BarToken */, - "^": 50 /* CaretToken */, - "!": 51 /* ExclamationToken */, - "~": 52 /* TildeToken */, - "&&": 53 /* AmpersandAmpersandToken */, - "||": 54 /* BarBarToken */, - "?": 55 /* QuestionToken */, - ":": 56 /* ColonToken */, - "=": 58 /* EqualsToken */, - "+=": 59 /* PlusEqualsToken */, - "-=": 60 /* MinusEqualsToken */, - "*=": 61 /* AsteriskEqualsToken */, - "**=": 62 /* AsteriskAsteriskEqualsToken */, - "/=": 63 /* SlashEqualsToken */, - "%=": 64 /* PercentEqualsToken */, - "<<=": 65 /* LessThanLessThanEqualsToken */, - ">>=": 66 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 68 /* AmpersandEqualsToken */, - "|=": 69 /* BarEqualsToken */, - "^=": 70 /* CaretEqualsToken */, - "@": 57 /* AtToken */, - }); + var textToKeywordObj = (_a = { + abstract: 117 /* AbstractKeyword */, + any: 119 /* AnyKeyword */, + as: 118 /* AsKeyword */, + boolean: 122 /* BooleanKeyword */, + break: 72 /* BreakKeyword */, + case: 73 /* CaseKeyword */, + catch: 74 /* CatchKeyword */, + class: 75 /* ClassKeyword */, + continue: 77 /* ContinueKeyword */, + const: 76 /* ConstKeyword */ + }, + _a["" + "constructor"] = 123 /* ConstructorKeyword */, + _a.debugger = 78 /* DebuggerKeyword */, + _a.declare = 124 /* DeclareKeyword */, + _a.default = 79 /* DefaultKeyword */, + _a.delete = 80 /* DeleteKeyword */, + _a.do = 81 /* DoKeyword */, + _a.else = 82 /* ElseKeyword */, + _a.enum = 83 /* EnumKeyword */, + _a.export = 84 /* ExportKeyword */, + _a.extends = 85 /* ExtendsKeyword */, + _a.false = 86 /* FalseKeyword */, + _a.finally = 87 /* FinallyKeyword */, + _a.for = 88 /* ForKeyword */, + _a.from = 143 /* FromKeyword */, + _a.function = 89 /* FunctionKeyword */, + _a.get = 125 /* GetKeyword */, + _a.if = 90 /* IfKeyword */, + _a.implements = 108 /* ImplementsKeyword */, + _a.import = 91 /* ImportKeyword */, + _a.in = 92 /* InKeyword */, + _a.infer = 126 /* InferKeyword */, + _a.instanceof = 93 /* InstanceOfKeyword */, + _a.interface = 109 /* InterfaceKeyword */, + _a.is = 127 /* IsKeyword */, + _a.keyof = 128 /* KeyOfKeyword */, + _a.let = 110 /* LetKeyword */, + _a.module = 129 /* ModuleKeyword */, + _a.namespace = 130 /* NamespaceKeyword */, + _a.never = 131 /* NeverKeyword */, + _a.new = 94 /* NewKeyword */, + _a.null = 95 /* NullKeyword */, + _a.number = 134 /* NumberKeyword */, + _a.object = 135 /* ObjectKeyword */, + _a.package = 111 /* PackageKeyword */, + _a.private = 112 /* PrivateKeyword */, + _a.protected = 113 /* ProtectedKeyword */, + _a.public = 114 /* PublicKeyword */, + _a.readonly = 132 /* ReadonlyKeyword */, + _a.require = 133 /* RequireKeyword */, + _a.global = 144 /* GlobalKeyword */, + _a.return = 96 /* ReturnKeyword */, + _a.set = 136 /* SetKeyword */, + _a.static = 115 /* StaticKeyword */, + _a.string = 137 /* StringKeyword */, + _a.super = 97 /* SuperKeyword */, + _a.switch = 98 /* SwitchKeyword */, + _a.symbol = 138 /* SymbolKeyword */, + _a.this = 99 /* ThisKeyword */, + _a.throw = 100 /* ThrowKeyword */, + _a.true = 101 /* TrueKeyword */, + _a.try = 102 /* TryKeyword */, + _a.type = 139 /* TypeKeyword */, + _a.typeof = 103 /* TypeOfKeyword */, + _a.undefined = 140 /* UndefinedKeyword */, + _a.unique = 141 /* UniqueKeyword */, + _a.unknown = 142 /* UnknownKeyword */, + _a.var = 104 /* VarKeyword */, + _a.void = 105 /* VoidKeyword */, + _a.while = 106 /* WhileKeyword */, + _a.with = 107 /* WithKeyword */, + _a.yield = 116 /* YieldKeyword */, + _a.async = 120 /* AsyncKeyword */, + _a.await = 121 /* AwaitKeyword */, + _a.of = 145 /* OfKeyword */, + _a); + var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); + var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 17 /* OpenBraceToken */, "}": 18 /* CloseBraceToken */, "(": 19 /* OpenParenToken */, ")": 20 /* CloseParenToken */, "[": 21 /* OpenBracketToken */, "]": 22 /* CloseBracketToken */, ".": 23 /* DotToken */, "...": 24 /* DotDotDotToken */, ";": 25 /* SemicolonToken */, ",": 26 /* CommaToken */, "<": 27 /* LessThanToken */, ">": 29 /* GreaterThanToken */, "<=": 30 /* LessThanEqualsToken */, ">=": 31 /* GreaterThanEqualsToken */, "==": 32 /* EqualsEqualsToken */, "!=": 33 /* ExclamationEqualsToken */, "===": 34 /* EqualsEqualsEqualsToken */, "!==": 35 /* ExclamationEqualsEqualsToken */, "=>": 36 /* EqualsGreaterThanToken */, "+": 37 /* PlusToken */, "-": 38 /* MinusToken */, "**": 40 /* AsteriskAsteriskToken */, "*": 39 /* AsteriskToken */, "/": 41 /* SlashToken */, "%": 42 /* PercentToken */, "++": 43 /* PlusPlusToken */, "--": 44 /* MinusMinusToken */, "<<": 45 /* LessThanLessThanToken */, ">": 46 /* GreaterThanGreaterThanToken */, ">>>": 47 /* GreaterThanGreaterThanGreaterThanToken */, "&": 48 /* AmpersandToken */, "|": 49 /* BarToken */, "^": 50 /* CaretToken */, "!": 51 /* ExclamationToken */, "~": 52 /* TildeToken */, "&&": 53 /* AmpersandAmpersandToken */, "||": 54 /* BarBarToken */, "?": 55 /* QuestionToken */, ":": 56 /* ColonToken */, "=": 58 /* EqualsToken */, "+=": 59 /* PlusEqualsToken */, "-=": 60 /* MinusEqualsToken */, "*=": 61 /* AsteriskEqualsToken */, "**=": 62 /* AsteriskAsteriskEqualsToken */, "/=": 63 /* SlashEqualsToken */, "%=": 64 /* PercentEqualsToken */, "<<=": 65 /* LessThanLessThanEqualsToken */, ">>=": 66 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 68 /* AmpersandEqualsToken */, "|=": 69 /* BarEqualsToken */, "^=": 70 /* CaretEqualsToken */, "@": 57 /* AtToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -7227,9 +7176,9 @@ var ts; if (len >= 2 && len <= 11) { var ch = tokenValue.charCodeAt(0); if (ch >= 97 /* a */ && ch <= 122 /* z */) { - token = textToToken.get(tokenValue); - if (token !== undefined) { - return token; + var keyword = textToKeyword.get(tokenValue); + if (keyword !== undefined) { + return token = keyword; } } } @@ -7909,7 +7858,7 @@ var ts; pos++; } tokenValue = text.substring(tokenPos, pos); - return token = 71 /* Identifier */; + return token = getIdentifierToken(); } else { return token = 0 /* Unknown */; @@ -21423,7 +21372,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(281 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -21618,7 +21567,7 @@ var ts; nextJSDocToken(); } } - function skipWhitespaceOrAsterisk(next) { + function skipWhitespaceOrAsterisk() { if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range @@ -21632,7 +21581,7 @@ var ts; else if (token() === 39 /* AsteriskToken */) { precedingLineBreak = false; } - next(); + nextJSDocToken(); } } function parseTag(indent) { @@ -21640,9 +21589,8 @@ var ts; var atToken = createNode(57 /* AtToken */, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); - // Use 'nextToken' instead of 'nextJsDocToken' so we can parse a type like 'number' in `@enum number` - var tagName = parseJSDocIdentifierName(/*message*/ undefined, nextToken); - skipWhitespaceOrAsterisk(nextToken); + var tagName = parseJSDocIdentifierName(/*message*/ undefined); + skipWhitespaceOrAsterisk(); var tag; switch (tagName.escapedText) { case "augments": @@ -21779,7 +21727,7 @@ var ts; tagsEnd = tag.end; } function tryParseTypeExpression() { - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); return token() === 17 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { @@ -21813,7 +21761,7 @@ var ts; function parseParameterOrPropertyTag(atToken, tagName, target, indent) { var typeExpression = tryParseTypeExpression(); var isNameFirst = !typeExpression; - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed; skipWhitespace(); if (isNameFirst) { @@ -21932,7 +21880,7 @@ var ts; } function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); var typedefTag = createNode(302 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; @@ -22165,8 +22113,7 @@ var ts; } return entity; } - function parseJSDocIdentifierName(message, next) { - if (next === void 0) { next = nextJSDocToken; } + function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { return createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } @@ -22175,7 +22122,7 @@ var ts; var result = createNode(71 /* Identifier */, pos); result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); finishNode(result, end); - next(); + nextJSDocToken(); return result; } } @@ -23661,30 +23608,6 @@ var ts; type: "object" }, description: ts.Diagnostics.List_of_language_service_plugins - }, - // extra options - { - name: "accessorOptimization", - type: "boolean" - }, - { - // this option can only be specified in tsconfig.json - // use type = object to copy the value as-is - name: "defines", - type: "object", - isTSConfigOnly: true - }, - { - name: "emitReflection", - type: "boolean" - }, - { - name: "noEmitJs", - type: "boolean" - }, - { - name: "reorderFiles", - type: "boolean" } ]); /* @internal */ @@ -23876,7 +23799,7 @@ var ts; i++; break; case "list": - var result = parseListTypeOption(opt, args[i], errors); + var result = parseListTypeOption(opt, args[i], errors); // tslint:disable-line no-unnecessary-type-assertion options[opt.name] = result || []; if (result) { i++; @@ -23998,8 +23921,7 @@ var ts; } /* @internal */ function printVersion() { - ts.sys.write("Version : " + ts.version_plus + ts.sys.newLine); - ts.sys.write("typescript-version : " + ts.version + ts.sys.newLine); + ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + ts.sys.newLine); } ts.printVersion = printVersion; /* @internal */ @@ -24411,7 +24333,7 @@ var ts; return undefined; } else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); // tslint:disable-line no-unnecessary-type-assertion } else { return optionDefinition.type; @@ -24474,7 +24396,7 @@ var ts; case "object": return {}; default: - return option.type.keys().next().value; + return option.type.keys().next().value; // tslint:disable-line no-unnecessary-type-assertion } } function makePadding(paddingLength) { @@ -24954,7 +24876,7 @@ var ts; if (isNullOrUndefined(value)) return undefined; if (option.type === "list") { - var listOption_1 = option; + var listOption_1 = option; // tslint:disable-line no-unnecessary-type-assertion if (listOption_1.element.isFilePath || !ts.isString(listOption_1.element.type)) { return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return !!v; }); } @@ -25298,7 +25220,7 @@ var ts; case "boolean": return typeof value === "boolean" ? value : ""; case "list": - var elementType_1 = option.element; + var elementType_1 = option.element; // tslint:disable-line no-unnecessary-type-assertion return ts.isArray(value) ? value.map(function (v) { return getOptionValueWithEmptyStrings(v, elementType_1); }) : ""; default: return ts.forEachEntry(option.type, function (optionEnumValue, optionStringValue) { @@ -56136,7 +56058,8 @@ var ts; return true; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 - if (target && ts.getModifierFlags(node) & 1 /* Export */ && target.flags & 67220415 /* Value */) { + if (target && ts.getModifierFlags(node) & 1 /* Export */ && + target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -69094,7 +69017,6 @@ var ts; var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); - var typeChecker = context.getEmitHost().getTypeChecker(); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; @@ -70027,13 +69949,7 @@ var ts; statements.push(transformSemicolonClassElementToStatement(member)); break; case 154 /* MethodDeclaration */: - var method = member; - if (method.isJumpTarget || (method.original && method.original.isJumpTarget)) { - transformJumpTarget(statements, getClassMemberPrefix(node, member), member); - } - else { - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); - } + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -70051,30 +69967,6 @@ var ts; } } } - function transformJumpTarget(statements, receiver, member) { - var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); - statements.push(ts.createStatement(ts.createAssignment(memberName, member.name))); - var sourceMapRange = ts.getSourceMapRange(member); - var memberFunction = transformMethodToFunctionDeclaration(member, /*location*/ member, /*name*/ member.name); - ts.setEmitFlags(memberFunction, 1536 /* NoComments */); - ts.setSourceMapRange(memberFunction, sourceMapRange); - statements.push(memberFunction); - } - function transformMethodToFunctionDeclaration(node, location, name) { - var savedConvertedLoopState = convertedLoopState; - convertedLoopState = undefined; - var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); - var parameters = ts.visitParameterList(node.parameters, visitor, context); - var body = transformFunctionBody(node); - exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); - convertedLoopState = savedConvertedLoopState; - return ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, node.asteriskToken, name, - /*typeParameters*/ undefined, parameters, - /*type*/ undefined, body), location), - /*original*/ node); - } /** * Transforms a SemicolonClassElement into a statement for a class body function. * @@ -70142,14 +70034,18 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterExpression = createAccessorExpression(getAccessor, firstAccessor, receiver, container); - var getter = ts.createPropertyAssignment("get", getterExpression); + var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); + ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); + ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); + var getter = ts.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); } if (setAccessor) { - var setterExpression = createAccessorExpression(setAccessor, firstAccessor, receiver, container); - var setter = ts.createPropertyAssignment("set", setterExpression); + var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); + ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); + ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); + var setter = ts.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } @@ -70167,75 +70063,6 @@ var ts; return call; } /** - * If the accessor method contains only one call to another method, use that method to define the accessor directly. - */ - function createAccessorExpression(accessor, firstAccessor, receiver, container) { - var expression; - var method = compilerOptions.accessorOptimization ? getJumpTargetOfAccessor(accessor) : null; - if (method) { - var methodName = ts.getMutableClone(method.name); - ts.setEmitFlags(methodName, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); - ts.setSourceMapRange(methodName, method.name); - if (firstAccessor.pos > method.pos) { // the target method has been already emitted. - var target = ts.getMutableClone(receiver); - ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); - ts.setSourceMapRange(target, firstAccessor.name); - expression = ts.createPropertyAccess(target, methodName); - } - else { - expression = methodName; - method.isJumpTarget = true; - } - } - else { - expression = transformFunctionLikeToExpression(accessor, /*location*/ undefined, /*name*/ undefined, container); - } - ts.setSourceMapRange(expression, ts.getSourceMapRange(accessor)); - ts.setEmitFlags(expression, 512 /* NoLeadingComments */); - return expression; - } - function getJumpTargetOfAccessor(accessor) { - if (accessor.body.statements.length != 1) { - return undefined; - } - var statement = accessor.body.statements[0]; - if (statement.kind !== 219 /* ExpressionStatement */ && - statement.kind !== 228 /* ReturnStatement */) { - return undefined; - } - var expression = statement.expression; - if (expression.kind !== 189 /* CallExpression */) { - return undefined; - } - var callExpression = expression; - if (accessor.kind === 157 /* SetAccessor */) { - if (callExpression.arguments.length != 1) { - return undefined; - } - var argument = callExpression.arguments[0]; - if (argument.kind !== 71 /* Identifier */) { - return undefined; - } - } - else { - if (callExpression.arguments.length != 0) { - return undefined; - } - } - if (callExpression.expression.kind !== 187 /* PropertyAccessExpression */) { - return undefined; - } - var propertyExpression = callExpression.expression; - if (propertyExpression.expression.kind !== 99 /* ThisKeyword */) { - return undefined; - } - var symbol = typeChecker.getSymbolAtLocation(propertyExpression.name); - if (!symbol) { - return undefined; - } - return ts.getDeclarationOfKind(symbol, 154 /* MethodDeclaration */); - } - /** * Visits an ArrowFunction and transforms it into a FunctionExpression. * * @param node An ArrowFunction node. @@ -79333,9 +79160,6 @@ var ts; var moduleKind = ts.getEmitModuleKind(compilerOptions); var transformers = []; ts.addRange(transformers, customTransformers && customTransformers.before); - if (compilerOptions.defines || compilerOptions.emitReflection) { - transformers.push(ts.transformTypeScriptPlus); - } transformers.push(ts.transformTypeScript); if (jsx === 2 /* React */) { transformers.push(ts.transformJsx); @@ -79632,976 +79456,6 @@ var ts; } ts.transformNodes = transformNodes; })(ts || (ts = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// The MIT License (MIT) -// -// Copyright (c) 2015-present, Dom Chen. -// All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in the -// Software without restriction, including without limitation the rights to use, copy, -// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, -// and to permit persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -////////////////////////////////////////////////////////////////////////////////////// -/*@internal*/ -var ts; -(function (ts) { - function transformTypeScriptPlus(context) { - var compilerOptions = context.getCompilerOptions(); - var compilerDefines = getCompilerDefines(compilerOptions.defines); - var typeChecker = compilerOptions.emitReflection || compilerDefines ? context.getEmitHost().getTypeChecker() : null; - var previousOnSubstituteNode = context.onSubstituteNode; - if (compilerDefines) { - context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(71 /* Identifier */); - } - return ts.chainBundle(transformSourceFile); - function transformSourceFile(node) { - if (!compilerOptions.emitReflection) { - return node; - } - var visited = ts.updateSourceFileNode(node, ts.visitNodes(node.statements, visitStatement, ts.isStatement)); - ts.addEmitHelpers(visited, context.readEmitHelpers()); - return visited; - } - function visitStatement(node) { - if (ts.hasModifier(node, 2 /* Ambient */)) { - return node; - } - if (node.kind === 238 /* ClassDeclaration */) { - return visitClassDeclaration(node); - } - if (node.kind === 242 /* ModuleDeclaration */) { - return visitModule(node); - } - return node; - } - function visitModule(node) { - if (node.body.kind === 242 /* ModuleDeclaration */) { - return updateModuleDeclaration(node, visitModule(node.body)); - } - if (node.body.kind === 243 /* ModuleBlock */) { - var body = updateModuleBlock(node.body, ts.visitNodes(node.body.statements, visitStatement, ts.isStatement)); - return updateModuleDeclaration(node, body); - } - return node; - } - function updateModuleDeclaration(node, body) { - if (node.body !== body) { - var updated = ts.getMutableClone(node); - updated.body = body; - return ts.updateNode(updated, node); - } - return node; - } - function updateModuleBlock(node, statements) { - if (node.statements !== statements) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements); - return ts.updateNode(updated, node); - } - return node; - } - function visitClassDeclaration(node) { - var classStatement = ts.getMutableClone(node); - var statements = [classStatement]; - var interfaceMap = {}; - getImplementedInterfaces(node, interfaceMap); - var allInterfaces = Object.keys(interfaceMap); - var interfaces; - var superTypes = getSuperClassTypes(node); - if (superTypes) { - interfaces = []; - for (var _i = 0, allInterfaces_1 = allInterfaces; _i < allInterfaces_1.length; _i++) { - var type = allInterfaces_1[_i]; - if (superTypes.indexOf(type) === -1) { - interfaces.push(type); - } - } - } - else { - interfaces = allInterfaces; - } - node.typeNames = interfaces; - var fullClassName = typeChecker.getFullyQualifiedName(node.symbol); - var expression = createReflectHelper(context, node.name, fullClassName, interfaces); - ts.setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); - var statement = ts.createStatement(expression); - ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); - statements.push(statement); - return statements; - } - function getImplementedInterfaces(node, result) { - var superInterfaces = undefined; - if (node.kind === 238 /* ClassDeclaration */) { - superInterfaces = ts.getClassImplementsHeritageClauseElements(node); - } - else { - superInterfaces = ts.getInterfaceBaseTypeNodes(node); - } - if (superInterfaces) { - superInterfaces.forEach(function (superInterface) { - var type = typeChecker.getTypeAtLocation(superInterface); - if (type && type.symbol && type.symbol.flags & 64 /* Interface */) { - var symbol = type.symbol; - var fullName = typeChecker.getFullyQualifiedName(symbol); - result[fullName] = true; - var declaration = ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); - if (declaration) { - getImplementedInterfaces(declaration, result); - } - } - }); - } - } - function getSuperClassTypes(node) { - var superClass = ts.getClassExtendsHeritageElement(node); - if (!superClass) { - return undefined; - } - var type = typeChecker.getTypeAtLocation(superClass); - if (!type || !type.symbol) { - return undefined; - } - var declaration = ts.getDeclarationOfKind(type.symbol, 238 /* ClassDeclaration */); - return declaration ? declaration.typeNames : undefined; - } - function getCompilerDefines(defines) { - if (!defines) { - return null; - } - var compilerDefines = {}; - var keys = Object.keys(defines); - for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { - var key = keys_1[_i]; - var value = defines[key]; - var type = typeof value; - switch (type) { - case "boolean": - case "number": - compilerDefines[key] = value.toString(); - break; - case "string": - compilerDefines[key] = "\"" + value + "\""; - break; - } - } - if (Object.keys(compilerDefines).length == 0) { - return null; - } - return compilerDefines; - } - function isDefinedConstant(node) { - var nodeText = ts.getTextOfIdentifierOrLiteral(node); - if (compilerDefines[nodeText] === undefined) { - return false; - } - if (!node.parent) { - return false; - } - if (node.parent.kind === 235 /* VariableDeclaration */ && node.parent.name === node) { - return false; - } - if (node.parent.kind === 202 /* BinaryExpression */) { - var parent = node.parent; - if (parent.left === node && parent.operatorToken.kind === 58 /* EqualsToken */) { - return false; - } - } - var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol || !symbol.declarations) { - return false; - } - var declaration = symbol.declarations[0]; - if (!declaration) { - return false; - } - if (declaration.kind !== 235 /* VariableDeclaration */) { - return false; - } - var statement = declaration.parent.parent; - return (statement.parent.kind === 277 /* SourceFile */); - } - /** - * Hooks node substitutions. - * @param emitContext The context for the emitter. - * @param node The node to substitute. - */ - function onSubstituteNode(hint, node) { - node = previousOnSubstituteNode(hint, node); - if (ts.isIdentifier(node) && isDefinedConstant(node)) { - var nodeText = ts.getTextOfIdentifierOrLiteral(node); - return ts.createIdentifier(compilerDefines[nodeText]); - } - return node; - } - } - ts.transformTypeScriptPlus = transformTypeScriptPlus; - var reflectHelper = { - name: "typescript:reflect", - scoped: false, - priority: 0, - text: "\n var __reflect = (this && this.__reflect) || function (p, c, t) {\n p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;\n };" - }; - function createReflectHelper(context, name, fullClassName, interfaces) { - context.requestEmitHelper(reflectHelper); - var argumentsArray = [ - ts.createPropertyAccess(name, ts.createIdentifier("prototype")), - ts.createLiteral(fullClassName) - ]; - if (interfaces.length) { - var elements = []; - for (var _i = 0, interfaces_1 = interfaces; _i < interfaces_1.length; _i++) { - var value = interfaces_1[_i]; - elements.push(ts.createLiteral(value)); - } - argumentsArray.push(ts.createArrayLiteral(elements)); - } - return ts.createCall(ts.getHelperName("__reflect"), - /*typeArguments*/ undefined, argumentsArray); - } -})(ts || (ts = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// The MIT License (MIT) -// -// Copyright (c) 2015-present, Dom Chen. -// All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in the -// Software without restriction, including without limitation the rights to use, copy, -// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, -// and to permit persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -////////////////////////////////////////////////////////////////////////////////////// -var ts; -(function (ts) { - var checker; - var sourceFiles; - var rootFileNames; - var dependencyMap; - var pathWeightMap; - var visitedBlocks; - var calledMethods = []; - function createMap() { - var map = Object.create(null); - // Using 'delete' on an object causes V8 to put the object in dictionary mode. - // This disables creation of hidden classes, which are expensive when an object is - // constantly changing shape. - map["__"] = undefined; - delete map["__"]; - return map; - } - function reorderSourceFiles(program) { - sourceFiles = program.getSourceFiles(); - rootFileNames = program.getRootFileNames(); - checker = program.getTypeChecker(); - visitedBlocks = []; - buildDependencyMap(); - var result = sortOnDependency(); - sourceFiles = []; - rootFileNames = []; - checker = null; - dependencyMap = null; - visitedBlocks = []; - return result; - } - ts.reorderSourceFiles = reorderSourceFiles; - function addDependency(file, dependent) { - if (file == dependent) { - return; - } - var list = dependencyMap[file]; - if (!list) { - list = dependencyMap[file] = []; - } - if (list.indexOf(dependent) == -1) { - list.push(dependent); - } - } - function buildDependencyMap() { - dependencyMap = createMap(); - for (var i = 0; i < sourceFiles.length; i++) { - var sourceFile = sourceFiles[i]; - if (sourceFile.isDeclarationFile) { - continue; - } - visitFile(sourceFile); - } - } - function visitFile(sourceFile) { - var statements = sourceFile.statements; - var length = statements.length; - for (var i = 0; i < length; i++) { - var statement = statements[i]; - if (ts.hasModifier(statement, 2 /* Ambient */)) { // has the 'declare' keyword - continue; - } - visitStatement(statements[i]); - } - } - function visitStatement(statement) { - if (!statement) { - return; - } - switch (statement.kind) { - case 219 /* ExpressionStatement */: - var expression = statement; - visitExpression(expression.expression); - break; - case 238 /* ClassDeclaration */: - checkInheriting(statement); - visitStaticMember(statement); - if (statement.transformFlags & 4096 /* ContainsDecorators */) { - visitClassDecorators(statement); - } - break; - case 217 /* VariableStatement */: - visitVariableList(statement.declarationList); - break; - case 246 /* ImportEqualsDeclaration */: - var importDeclaration = statement; - checkDependencyAtLocation(importDeclaration.moduleReference); - break; - case 242 /* ModuleDeclaration */: - visitModule(statement); - break; - case 216 /* Block */: - visitBlock(statement); - break; - case 220 /* IfStatement */: - var ifStatement = statement; - visitExpression(ifStatement.expression); - visitStatement(ifStatement.thenStatement); - visitStatement(ifStatement.elseStatement); - break; - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - var doStatement = statement; - visitExpression(doStatement.expression); - visitStatement(doStatement.statement); - break; - case 223 /* ForStatement */: - var forStatement = statement; - visitExpression(forStatement.condition); - visitExpression(forStatement.incrementor); - if (forStatement.initializer) { - if (forStatement.initializer.kind === 236 /* VariableDeclarationList */) { - visitVariableList(forStatement.initializer); - } - else { - visitExpression(forStatement.initializer); - } - } - break; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - var forInStatement = statement; - visitExpression(forInStatement.expression); - if (forInStatement.initializer) { - if (forInStatement.initializer.kind === 236 /* VariableDeclarationList */) { - visitVariableList(forInStatement.initializer); - } - else { - visitExpression(forInStatement.initializer); - } - } - break; - case 228 /* ReturnStatement */: - visitExpression(statement.expression); - break; - case 230 /* SwitchStatement */: - var switchStatment = statement; - visitExpression(switchStatment.expression); - switchStatment.caseBlock.clauses.forEach(function (element) { - if (element.kind === 269 /* CaseClause */) { - visitExpression(element.expression); - } - element.statements.forEach(function (element) { - visitStatement(element); - }); - }); - break; - case 231 /* LabeledStatement */: - visitStatement(statement.statement); - break; - case 232 /* ThrowStatement */: - visitExpression(statement.expression); - break; - case 233 /* TryStatement */: - var tryStatement = statement; - visitBlock(tryStatement.tryBlock); - visitBlock(tryStatement.finallyBlock); - if (tryStatement.catchClause) { - visitBlock(tryStatement.catchClause.block); - } - break; - } - } - function visitModule(node) { - if (node.body.kind === 242 /* ModuleDeclaration */) { - visitModule(node.body); - return; - } - if (node.body.kind === 243 /* ModuleBlock */) { - for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (ts.hasModifier(statement, 2 /* Ambient */)) { // has the 'declare' keyword - continue; - } - visitStatement(statement); - } - } - } - function checkDependencyAtLocation(node) { - var symbol = checker.getSymbolAtLocation(node); - if (!symbol || !symbol.declarations) { - return; - } - var sourceFile = getSourceFileOfNode(symbol.declarations[0]); - if (!sourceFile || sourceFile.isDeclarationFile) { - return; - } - addDependency(getSourceFileOfNode(node).fileName, sourceFile.fileName); - } - function checkInheriting(node) { - if (!node.heritageClauses) { - return; - } - var heritageClause = null; - for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { - var clause = _a[_i]; - if (clause.token === 85 /* ExtendsKeyword */) { - heritageClause = clause; - break; - } - } - if (!heritageClause) { - return; - } - var superClasses = heritageClause.types; - if (!superClasses) { - return; - } - superClasses.forEach(function (superClass) { - checkDependencyAtLocation(superClass.expression); - }); - } - function visitStaticMember(node) { - var members = node.members; - if (!members) { - return; - } - for (var _i = 0, members_6 = members; _i < members_6.length; _i++) { - var member = members_6[_i]; - if (!ts.hasModifier(member, 32 /* Static */)) { - continue; - } - if (member.kind == 152 /* PropertyDeclaration */) { - var property = member; - visitExpression(property.initializer); - } - } - } - function visitClassDecorators(node) { - if (node.decorators) { - visitDecorators(node.decorators); - } - var members = node.members; - if (!members) { - return; - } - for (var _i = 0, members_7 = members; _i < members_7.length; _i++) { - var member = members_7[_i]; - var decorators = void 0; - var functionLikeMember = void 0; - if (member.kind === 156 /* GetAccessor */ || member.kind === 157 /* SetAccessor */) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member !== accessors.firstAccessor) { - continue; - } - decorators = accessors.firstAccessor.decorators; - if (!decorators && accessors.secondAccessor) { - decorators = accessors.secondAccessor.decorators; - } - functionLikeMember = accessors.setAccessor; - } - else { - decorators = member.decorators; - if (member.kind === 154 /* MethodDeclaration */) { - functionLikeMember = member; - } - } - if (decorators) { - visitDecorators(decorators); - } - if (functionLikeMember) { - for (var _a = 0, _b = functionLikeMember.parameters; _a < _b.length; _a++) { - var parameter = _b[_a]; - if (parameter.decorators) { - visitDecorators(parameter.decorators); - } - } - } - } - } - function visitDecorators(decorators) { - for (var _i = 0, decorators_2 = decorators; _i < decorators_2.length; _i++) { - var decorator = decorators_2[_i]; - visitCallExpression(decorator.expression); - } - } - function visitExpression(expression) { - if (!expression) { - return; - } - switch (expression.kind) { - case 190 /* NewExpression */: - case 189 /* CallExpression */: - visitCallArguments(expression); - visitCallExpression(expression.expression); - break; - case 71 /* Identifier */: - checkDependencyAtLocation(expression); - break; - case 187 /* PropertyAccessExpression */: - checkDependencyAtLocation(expression); - break; - case 188 /* ElementAccessExpression */: - visitExpression(expression.expression); - break; - case 186 /* ObjectLiteralExpression */: - visitObjectLiteralExpression(expression); - break; - case 185 /* ArrayLiteralExpression */: - var arrayLiteral = expression; - arrayLiteral.elements.forEach(visitExpression); - break; - case 204 /* TemplateExpression */: - var template = expression; - template.templateSpans.forEach(function (span) { - visitExpression(span.expression); - }); - break; - case 193 /* ParenthesizedExpression */: - var parenthesized = expression; - visitExpression(parenthesized.expression); - break; - case 202 /* BinaryExpression */: - visitBinaryExpression(expression); - break; - case 201 /* PostfixUnaryExpression */: - case 200 /* PrefixUnaryExpression */: - visitExpression(expression.operand); - break; - case 196 /* DeleteExpression */: - visitExpression(expression.expression); - break; - case 191 /* TaggedTemplateExpression */: - visitExpression(expression.tag); - visitExpression(expression.template); - break; - case 203 /* ConditionalExpression */: - visitExpression(expression.condition); - visitExpression(expression.whenTrue); - visitExpression(expression.whenFalse); - break; - case 206 /* SpreadElement */: - visitExpression(expression.expression); - break; - case 198 /* VoidExpression */: - visitExpression(expression.expression); - break; - case 205 /* YieldExpression */: - visitExpression(expression.expression); - break; - case 199 /* AwaitExpression */: - visitExpression(expression.expression); - break; - case 197 /* TypeOfExpression */: - visitExpression(expression.expression); - break; - case 211 /* NonNullExpression */: - visitExpression(expression.expression); - break; - case 192 /* TypeAssertionExpression */: - visitExpression(expression.expression); - break; - } - // FunctionExpression - // ArrowFunction - // ClassExpression - // OmittedExpression - // ExpressionWithTypeArguments - // AsExpression - } - function visitBinaryExpression(binary) { - var left = binary.left; - var right = binary.right; - visitExpression(left); - visitExpression(right); - if (binary.operatorToken.kind === 58 /* EqualsToken */ && - (left.kind === 71 /* Identifier */ || left.kind === 187 /* PropertyAccessExpression */) && - (right.kind === 71 /* Identifier */ || right.kind === 187 /* PropertyAccessExpression */)) { - var symbol = checker.getSymbolAtLocation(left); - if (!symbol || !symbol.declarations) { - return; - } - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 235 /* VariableDeclaration */ || declaration.kind === 152 /* PropertyDeclaration */) { - var variable = declaration; - if (variable.initializer) { - continue; - } - if (!variable.delayInitializerList) { - variable.delayInitializerList = []; - } - variable.delayInitializerList.push(right); - if (variable.callerList) { - for (var _b = 0, _c = variable.callerList; _b < _c.length; _b++) { - var callerFileName = _c[_b]; - checkCallTarget(callerFileName, right); - } - } - } - } - } - } - function visitObjectLiteralExpression(objectLiteral) { - objectLiteral.properties.forEach(function (element) { - switch (element.kind) { - case 273 /* PropertyAssignment */: - visitExpression(element.initializer); - break; - case 274 /* ShorthandPropertyAssignment */: - visitExpression(element.objectAssignmentInitializer); - break; - case 275 /* SpreadAssignment */: - visitExpression(element.expression); - break; - } - }); - } - function visitCallArguments(callExpression) { - if (callExpression.arguments) { - callExpression.arguments.forEach(function (argument) { - visitExpression(argument); - }); - } - } - function visitCallExpression(expression) { - expression = escapeParenthesized(expression); - visitExpression(expression); - switch (expression.kind) { - case 194 /* FunctionExpression */: - var functionExpression = expression; - visitBlock(functionExpression.body); - break; - case 187 /* PropertyAccessExpression */: - case 71 /* Identifier */: - var callerFileName = getSourceFileOfNode(expression).fileName; - checkCallTarget(callerFileName, expression); - break; - case 189 /* CallExpression */: - visitReturnedFunction(expression.expression); - break; - } - } - function visitReturnedFunction(expression) { - expression = escapeParenthesized(expression); - var returnExpressions = []; - if (expression.kind === 189 /* CallExpression */) { - var expressions = visitReturnedFunction(expression.expression); - for (var _i = 0, expressions_2 = expressions; _i < expressions_2.length; _i++) { - var returnExpression = expressions_2[_i]; - var returns = visitReturnedFunction(returnExpression); - returnExpressions = returnExpressions.concat(returns); - } - return returnExpressions; - } - var functionBlocks = []; - switch (expression.kind) { - case 194 /* FunctionExpression */: - functionBlocks.push(expression.body); - break; - case 187 /* PropertyAccessExpression */: - case 71 /* Identifier */: - var callerFileName = getSourceFileOfNode(expression).fileName; - var declarations = []; - getForwardDeclarations(expression, declarations, callerFileName); - for (var _a = 0, declarations_11 = declarations; _a < declarations_11.length; _a++) { - var declaration = declarations_11[_a]; - var sourceFile = getSourceFileOfNode(declaration); - if (!sourceFile || sourceFile.isDeclarationFile) { - continue; - } - if (declaration.kind === 237 /* FunctionDeclaration */ || - declaration.kind === 154 /* MethodDeclaration */) { - functionBlocks.push(declaration.body); - } - } - break; - } - for (var _b = 0, functionBlocks_1 = functionBlocks; _b < functionBlocks_1.length; _b++) { - var block = functionBlocks_1[_b]; - for (var _c = 0, _d = block.statements; _c < _d.length; _c++) { - var statement = _d[_c]; - if (statement.kind === 228 /* ReturnStatement */) { - var returnExpression = statement.expression; - returnExpressions.push(returnExpression); - visitCallExpression(returnExpression); - } - } - } - return returnExpressions; - } - function escapeParenthesized(expression) { - if (expression.kind === 193 /* ParenthesizedExpression */) { - return escapeParenthesized(expression.expression); - } - return expression; - } - function checkCallTarget(callerFileName, target) { - var declarations = []; - getForwardDeclarations(target, declarations, callerFileName); - for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { - var declaration = declarations_12[_i]; - var sourceFile = getSourceFileOfNode(declaration); - if (!sourceFile || sourceFile.isDeclarationFile) { - continue; - } - addDependency(callerFileName, sourceFile.fileName); - if (declaration.kind === 237 /* FunctionDeclaration */) { - visitBlock(declaration.body); - } - else if (declaration.kind === 154 /* MethodDeclaration */) { - visitBlock(declaration.body); - calledMethods.push(declaration); - } - else if (declaration.kind === 238 /* ClassDeclaration */) { - checkClassInstantiation(declaration); - } - } - } - function getForwardDeclarations(reference, declarations, callerFileName) { - var symbol = checker.getSymbolAtLocation(reference); - if (!symbol || !symbol.declarations) { - return; - } - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - switch (declaration.kind) { - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 238 /* ClassDeclaration */: - if (declarations.indexOf(declaration) == -1) { - declarations.push(declaration); - } - break; - case 246 /* ImportEqualsDeclaration */: - getForwardDeclarations(declaration.moduleReference, declarations, callerFileName); - break; - case 235 /* VariableDeclaration */: - case 152 /* PropertyDeclaration */: - var variable = declaration; - var initializer = variable.initializer; - if (initializer) { - if (initializer.kind === 71 /* Identifier */ || initializer.kind === 187 /* PropertyAccessExpression */) { - getForwardDeclarations(initializer, declarations, callerFileName); - } - } - else { - if (variable.delayInitializerList) { - for (var _b = 0, _c = variable.delayInitializerList; _b < _c.length; _b++) { - var expression = _c[_b]; - getForwardDeclarations(expression, declarations, callerFileName); - } - } - if (variable.callerList) { - if (variable.callerList.indexOf(callerFileName) == -1) { - variable.callerList.push(callerFileName); - } - } - else { - variable.callerList = [callerFileName]; - } - } - break; - } - } - } - function checkClassInstantiation(node) { - var methodNames = []; - var superClass = ts.getClassExtendsHeritageElement(node); - if (superClass) { - var type = checker.getTypeAtLocation(superClass); - if (type && type.symbol) { - var declaration = ts.getDeclarationOfKind(type.symbol, 238 /* ClassDeclaration */); - if (declaration) { - methodNames = checkClassInstantiation(declaration); - } - } - } - var members = node.members; - if (!members) { - return []; - } - var index = calledMethods.length; - for (var _i = 0, members_8 = members; _i < members_8.length; _i++) { - var member = members_8[_i]; - if (ts.hasModifier(member, 32 /* Static */)) { - continue; - } - if (member.kind === 154 /* MethodDeclaration */) { // called by super class. - var methodName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name)); - if (methodNames.indexOf(methodName) != -1) { - visitBlock(member.body); - } - } - if (member.kind === 152 /* PropertyDeclaration */) { - var property = member; - visitExpression(property.initializer); - } - else if (member.kind === 155 /* Constructor */) { - var constructor = member; - visitBlock(constructor.body); - } - } - for (var i = index; i < calledMethods.length; i++) { - var method = calledMethods[i]; - for (var _a = 0, members_9 = members; _a < members_9.length; _a++) { - var memeber = members_9[_a]; - if (memeber === method) { - var methodName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(method.name)); - methodNames.push(methodName); - } - } - } - if (index == 0) { - calledMethods.length = 0; - } - return methodNames; - } - function visitBlock(block) { - if (!block || visitedBlocks.indexOf(block) != -1) { - return; - } - visitedBlocks.push(block); - for (var _i = 0, _a = block.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - visitStatement(statement); - } - visitedBlocks.pop(); - } - function visitVariableList(variables) { - if (!variables) { - return; - } - variables.declarations.forEach(function (declaration) { - visitExpression(declaration.initializer); - }); - } - function sortOnDependency() { - var result = {}; - result.sortedFileNames = []; - result.circularReferences = []; - pathWeightMap = createMap(); - var dtsFiles = []; - var tsFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var path = sourceFile.fileName; - if (sourceFile.isDeclarationFile) { - pathWeightMap[path] = 10000; - dtsFiles.push(sourceFile); - continue; - } - var references = updatePathWeight(path, 0, [path]); - if (references.length > 0) { - result.circularReferences = references; - break; - } - tsFiles.push(sourceFile); - } - if (result.circularReferences.length === 0) { - tsFiles.sort(function (a, b) { - return pathWeightMap[b.fileName] - pathWeightMap[a.fileName]; - }); - sourceFiles.length = 0; - rootFileNames.length = 0; - dtsFiles.concat(tsFiles).forEach(function (sourceFile) { - sourceFiles.push(sourceFile); - rootFileNames.push(sourceFile.fileName); - result.sortedFileNames.push(sourceFile.fileName); - }); - } - pathWeightMap = null; - return result; - } - function updatePathWeight(path, weight, references) { - if (pathWeightMap[path] === undefined) { - pathWeightMap[path] = weight; - } - else { - if (pathWeightMap[path] < weight) { - pathWeightMap[path] = weight; - } - else { - return []; - } - } - var list = dependencyMap[path]; - if (!list) { - return []; - } - for (var _i = 0, list_3 = list; _i < list_3.length; _i++) { - var parentPath = list_3[_i]; - if (references.indexOf(parentPath) != -1) { - references.push(parentPath); - return references; - } - var result = updatePathWeight(parentPath, weight + 1, references.concat(parentPath)); - if (result.length > 0) { - return result; - } - } - return []; - } - function getSourceFileOfNode(node) { - while (node && node.kind !== 277 /* SourceFile */) { - node = node.parent; - } - return node; - } -})(ts || (ts = {})); /* @internal */ var ts; (function (ts) { @@ -81445,8 +80299,8 @@ var ts; } } else { - for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { - var sourceFile = sourceFiles_2[_a]; + for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { + var sourceFile = sourceFiles_1[_a]; var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); if (result) { return result; @@ -86117,7 +84971,7 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - 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, getTypeChecker: program.getTypeChecker, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + 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, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches var path = toPath(f); if (getSourceFileByPath(path)) @@ -87063,8 +85917,8 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var sourceFile = sourceFiles_2[_i]; if (!sourceFile.isDeclarationFile) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -97750,8 +96604,8 @@ var ts; function findModuleReferences(program, sourceFiles, searchModuleSymbol) { var refs = []; var checker = program.getTypeChecker(); - for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { - var referencingFile = sourceFiles_4[_i]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var referencingFile = sourceFiles_3[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; if (searchSourceFile.kind === 277 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { @@ -97781,8 +96635,8 @@ var ts; /** Returns a map from a module symbol Id to all import statements that directly reference the module. */ function getDirectImportsMap(sourceFiles, checker, cancellationToken) { var map = ts.createMap(); - for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { - var sourceFile = sourceFiles_5[_i]; + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); forEachImport(sourceFile, function (importDecl, moduleSpecifier) { @@ -98714,8 +97568,8 @@ var ts; return undefined; } var scope; - for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { - var declaration = declarations_13[_i]; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; var container = ts.getContainerNode(declaration); if (scope && scope !== container) { // Different declarations have different containers, bail out @@ -98764,8 +97618,8 @@ var ts; if (!signature.name || !ts.isIdentifier(signature.name)) return; var symbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(signature.name)); - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var sourceFile = sourceFiles_6[_i]; + for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { + var sourceFile = sourceFiles_5[_i]; for (var _a = 0, _b = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _a < _b.length; _a++) { var name = _b[_a]; if (!ts.isIdentifier(name) || name === signature.name || name.escapedText !== signature.name.escapedText) @@ -99430,8 +98284,8 @@ var ts; // To achieve that we will keep iterating until the result stabilizes. // Remember the last meaning lastIterationMeaning = meaning; - for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { - var declaration = declarations_14[_i]; + for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { + var declaration = declarations_12[_i]; var declarationMeaning = ts.getMeaningFromDeclaration(declaration); if (declarationMeaning & meaning) { meaning |= declarationMeaning; @@ -99554,7 +98408,7 @@ var ts; case "compilerOptions": forEachProperty(property.initializer, function (property, propertyName) { var option = ts.getOptionFromName(propertyName); - if (option && (option.isFilePath || option.type === "list" && option.element.isFilePath)) { + if (option && (option.isFilePath || option.type === "list" && option.element.isFilePath)) { // tslint:disable-line no-unnecessary-type-assertion updatePaths(property); } else if (propertyName === "paths") { @@ -100421,8 +99275,8 @@ var ts; }); }; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var sourceFile = sourceFiles_6[_i]; _loop_12(sourceFile); } rawItems.sort(compareNavigateToItems); @@ -100436,8 +99290,8 @@ var ts; if (!match) { return; // continue to next named declarations } - for (var _i = 0, declarations_15 = declarations; _i < declarations_15.length; _i++) { - var declaration = declarations_15[_i]; + for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { + var declaration = declarations_13[_i]; if (!shouldKeepItem(declaration, checker)) continue; if (patternMatcher.patternContainsDots) { @@ -111703,7 +110557,7 @@ var ts; return checker.createArrayType(recur(usageContext.numberIndexContext)); } else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { - var members_10 = ts.createUnderscoreEscapedMap(); + var members_6 = ts.createUnderscoreEscapedMap(); var callSignatures = []; var constructSignatures = []; var stringIndexInfo = void 0; @@ -111711,7 +110565,7 @@ var ts; usageContext.properties.forEach(function (context, name) { var symbol = checker.createSymbol(4 /* Property */, name); symbol.type = recur(context); - members_10.set(name, symbol); + members_6.set(name, symbol); }); } if (usageContext.callContexts) { @@ -111729,7 +110583,7 @@ var ts; if (usageContext.stringIndexContext) { stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); } - return checker.createAnonymousType(/*symbol*/ undefined, members_10, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 + return checker.createAnonymousType(/*symbol*/ undefined, members_6, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 } else { return undefined; @@ -113708,8 +112562,8 @@ var ts; ts.Debug.assert(members.length > 0); // There must be at least one child, since we extracted from one. var prevMember; var allProperties = true; - for (var _i = 0, members_11 = members; _i < members_11.length; _i++) { - var member = members_11[_i]; + for (var _i = 0, members_7 = members; _i < members_7.length; _i++) { + var member = members_7[_i]; if (member.pos > maxPos) { return prevMember || members[0]; } @@ -115495,8 +114349,8 @@ var ts; return ts.emptyArray; var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations); if (doc.length === 0 || declarations.some(hasJSDocInheritDocTag)) { - for (var _i = 0, declarations_16 = declarations; _i < declarations_16.length; _i++) { - var declaration = declarations_16[_i]; + for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { + var declaration = declarations_14[_i]; var inheritedDocs = findInheritedJSDocComments(declaration, declaration.symbol.name, checker); // TODO: GH#18217 // TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs if (inheritedDocs) @@ -116183,11 +115037,7 @@ var ts; /// Diagnostics function getSyntacticDiagnostics(fileName) { synchronizeHostData(); - var targetSourceFile; - if (fileName) { - targetSourceFile = getValidSourceFile(fileName); - } - return program.getSyntacticDiagnostics(targetSourceFile, cancellationToken).slice(); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken).slice(); } /** * getSemanticDiagnostics return array of Diagnostics. If '-d' is not enabled, only report semantic errors @@ -116195,10 +115045,7 @@ var ts; */ function getSemanticDiagnostics(fileName) { synchronizeHostData(); - var targetSourceFile; - if (fileName) { - targetSourceFile = getValidSourceFile(fileName); - } + var targetSourceFile = getValidSourceFile(fileName); // Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file. // Therefore only get diagnostics for given file. var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); @@ -116360,10 +115207,7 @@ var ts; function getEmitOutput(fileName, emitOnlyDtsFiles) { if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } synchronizeHostData(); - var sourceFile; - if (fileName) { - sourceFile = getValidSourceFile(fileName); - } + var sourceFile = getValidSourceFile(fileName); var customTransformers = host.getCustomTransformers && host.getCustomTransformers(); return ts.getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers); } diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 46019ea8c..f6db7e4e3 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -88,8 +88,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.1"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".3"; - ts.version_plus = "3.1.5"; + ts.version = ts.versionMajorMinor + ".5"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -6095,6 +6094,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { return token >= 71 /* Identifier */; @@ -6105,136 +6105,85 @@ var ts; return token === 29 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; - var textToToken = ts.createMapFromTemplate({ - "abstract": 117 /* AbstractKeyword */, - "any": 119 /* AnyKeyword */, - "as": 118 /* AsKeyword */, - "boolean": 122 /* BooleanKeyword */, - "break": 72 /* BreakKeyword */, - "case": 73 /* CaseKeyword */, - "catch": 74 /* CatchKeyword */, - "class": 75 /* ClassKeyword */, - "continue": 77 /* ContinueKeyword */, - "const": 76 /* ConstKeyword */, - "constructor": 123 /* ConstructorKeyword */, - "debugger": 78 /* DebuggerKeyword */, - "declare": 124 /* DeclareKeyword */, - "default": 79 /* DefaultKeyword */, - "delete": 80 /* DeleteKeyword */, - "do": 81 /* DoKeyword */, - "else": 82 /* ElseKeyword */, - "enum": 83 /* EnumKeyword */, - "export": 84 /* ExportKeyword */, - "extends": 85 /* ExtendsKeyword */, - "false": 86 /* FalseKeyword */, - "finally": 87 /* FinallyKeyword */, - "for": 88 /* ForKeyword */, - "from": 143 /* FromKeyword */, - "function": 89 /* FunctionKeyword */, - "get": 125 /* GetKeyword */, - "if": 90 /* IfKeyword */, - "implements": 108 /* ImplementsKeyword */, - "import": 91 /* ImportKeyword */, - "in": 92 /* InKeyword */, - "infer": 126 /* InferKeyword */, - "instanceof": 93 /* InstanceOfKeyword */, - "interface": 109 /* InterfaceKeyword */, - "is": 127 /* IsKeyword */, - "keyof": 128 /* KeyOfKeyword */, - "let": 110 /* LetKeyword */, - "module": 129 /* ModuleKeyword */, - "namespace": 130 /* NamespaceKeyword */, - "never": 131 /* NeverKeyword */, - "new": 94 /* NewKeyword */, - "null": 95 /* NullKeyword */, - "number": 134 /* NumberKeyword */, - "object": 135 /* ObjectKeyword */, - "package": 111 /* PackageKeyword */, - "private": 112 /* PrivateKeyword */, - "protected": 113 /* ProtectedKeyword */, - "public": 114 /* PublicKeyword */, - "readonly": 132 /* ReadonlyKeyword */, - "require": 133 /* RequireKeyword */, - "global": 144 /* GlobalKeyword */, - "return": 96 /* ReturnKeyword */, - "set": 136 /* SetKeyword */, - "static": 115 /* StaticKeyword */, - "string": 137 /* StringKeyword */, - "super": 97 /* SuperKeyword */, - "switch": 98 /* SwitchKeyword */, - "symbol": 138 /* SymbolKeyword */, - "this": 99 /* ThisKeyword */, - "throw": 100 /* ThrowKeyword */, - "true": 101 /* TrueKeyword */, - "try": 102 /* TryKeyword */, - "type": 139 /* TypeKeyword */, - "typeof": 103 /* TypeOfKeyword */, - "undefined": 140 /* UndefinedKeyword */, - "unique": 141 /* UniqueKeyword */, - "unknown": 142 /* UnknownKeyword */, - "var": 104 /* VarKeyword */, - "void": 105 /* VoidKeyword */, - "while": 106 /* WhileKeyword */, - "with": 107 /* WithKeyword */, - "yield": 116 /* YieldKeyword */, - "async": 120 /* AsyncKeyword */, - "await": 121 /* AwaitKeyword */, - "of": 145 /* OfKeyword */, - "{": 17 /* OpenBraceToken */, - "}": 18 /* CloseBraceToken */, - "(": 19 /* OpenParenToken */, - ")": 20 /* CloseParenToken */, - "[": 21 /* OpenBracketToken */, - "]": 22 /* CloseBracketToken */, - ".": 23 /* DotToken */, - "...": 24 /* DotDotDotToken */, - ";": 25 /* SemicolonToken */, - ",": 26 /* CommaToken */, - "<": 27 /* LessThanToken */, - ">": 29 /* GreaterThanToken */, - "<=": 30 /* LessThanEqualsToken */, - ">=": 31 /* GreaterThanEqualsToken */, - "==": 32 /* EqualsEqualsToken */, - "!=": 33 /* ExclamationEqualsToken */, - "===": 34 /* EqualsEqualsEqualsToken */, - "!==": 35 /* ExclamationEqualsEqualsToken */, - "=>": 36 /* EqualsGreaterThanToken */, - "+": 37 /* PlusToken */, - "-": 38 /* MinusToken */, - "**": 40 /* AsteriskAsteriskToken */, - "*": 39 /* AsteriskToken */, - "/": 41 /* SlashToken */, - "%": 42 /* PercentToken */, - "++": 43 /* PlusPlusToken */, - "--": 44 /* MinusMinusToken */, - "<<": 45 /* LessThanLessThanToken */, - ">": 46 /* GreaterThanGreaterThanToken */, - ">>>": 47 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 48 /* AmpersandToken */, - "|": 49 /* BarToken */, - "^": 50 /* CaretToken */, - "!": 51 /* ExclamationToken */, - "~": 52 /* TildeToken */, - "&&": 53 /* AmpersandAmpersandToken */, - "||": 54 /* BarBarToken */, - "?": 55 /* QuestionToken */, - ":": 56 /* ColonToken */, - "=": 58 /* EqualsToken */, - "+=": 59 /* PlusEqualsToken */, - "-=": 60 /* MinusEqualsToken */, - "*=": 61 /* AsteriskEqualsToken */, - "**=": 62 /* AsteriskAsteriskEqualsToken */, - "/=": 63 /* SlashEqualsToken */, - "%=": 64 /* PercentEqualsToken */, - "<<=": 65 /* LessThanLessThanEqualsToken */, - ">>=": 66 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 68 /* AmpersandEqualsToken */, - "|=": 69 /* BarEqualsToken */, - "^=": 70 /* CaretEqualsToken */, - "@": 57 /* AtToken */, - }); + var textToKeywordObj = (_a = { + abstract: 117 /* AbstractKeyword */, + any: 119 /* AnyKeyword */, + as: 118 /* AsKeyword */, + boolean: 122 /* BooleanKeyword */, + break: 72 /* BreakKeyword */, + case: 73 /* CaseKeyword */, + catch: 74 /* CatchKeyword */, + class: 75 /* ClassKeyword */, + continue: 77 /* ContinueKeyword */, + const: 76 /* ConstKeyword */ + }, + _a["" + "constructor"] = 123 /* ConstructorKeyword */, + _a.debugger = 78 /* DebuggerKeyword */, + _a.declare = 124 /* DeclareKeyword */, + _a.default = 79 /* DefaultKeyword */, + _a.delete = 80 /* DeleteKeyword */, + _a.do = 81 /* DoKeyword */, + _a.else = 82 /* ElseKeyword */, + _a.enum = 83 /* EnumKeyword */, + _a.export = 84 /* ExportKeyword */, + _a.extends = 85 /* ExtendsKeyword */, + _a.false = 86 /* FalseKeyword */, + _a.finally = 87 /* FinallyKeyword */, + _a.for = 88 /* ForKeyword */, + _a.from = 143 /* FromKeyword */, + _a.function = 89 /* FunctionKeyword */, + _a.get = 125 /* GetKeyword */, + _a.if = 90 /* IfKeyword */, + _a.implements = 108 /* ImplementsKeyword */, + _a.import = 91 /* ImportKeyword */, + _a.in = 92 /* InKeyword */, + _a.infer = 126 /* InferKeyword */, + _a.instanceof = 93 /* InstanceOfKeyword */, + _a.interface = 109 /* InterfaceKeyword */, + _a.is = 127 /* IsKeyword */, + _a.keyof = 128 /* KeyOfKeyword */, + _a.let = 110 /* LetKeyword */, + _a.module = 129 /* ModuleKeyword */, + _a.namespace = 130 /* NamespaceKeyword */, + _a.never = 131 /* NeverKeyword */, + _a.new = 94 /* NewKeyword */, + _a.null = 95 /* NullKeyword */, + _a.number = 134 /* NumberKeyword */, + _a.object = 135 /* ObjectKeyword */, + _a.package = 111 /* PackageKeyword */, + _a.private = 112 /* PrivateKeyword */, + _a.protected = 113 /* ProtectedKeyword */, + _a.public = 114 /* PublicKeyword */, + _a.readonly = 132 /* ReadonlyKeyword */, + _a.require = 133 /* RequireKeyword */, + _a.global = 144 /* GlobalKeyword */, + _a.return = 96 /* ReturnKeyword */, + _a.set = 136 /* SetKeyword */, + _a.static = 115 /* StaticKeyword */, + _a.string = 137 /* StringKeyword */, + _a.super = 97 /* SuperKeyword */, + _a.switch = 98 /* SwitchKeyword */, + _a.symbol = 138 /* SymbolKeyword */, + _a.this = 99 /* ThisKeyword */, + _a.throw = 100 /* ThrowKeyword */, + _a.true = 101 /* TrueKeyword */, + _a.try = 102 /* TryKeyword */, + _a.type = 139 /* TypeKeyword */, + _a.typeof = 103 /* TypeOfKeyword */, + _a.undefined = 140 /* UndefinedKeyword */, + _a.unique = 141 /* UniqueKeyword */, + _a.unknown = 142 /* UnknownKeyword */, + _a.var = 104 /* VarKeyword */, + _a.void = 105 /* VoidKeyword */, + _a.while = 106 /* WhileKeyword */, + _a.with = 107 /* WithKeyword */, + _a.yield = 116 /* YieldKeyword */, + _a.async = 120 /* AsyncKeyword */, + _a.await = 121 /* AwaitKeyword */, + _a.of = 145 /* OfKeyword */, + _a); + var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); + var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 17 /* OpenBraceToken */, "}": 18 /* CloseBraceToken */, "(": 19 /* OpenParenToken */, ")": 20 /* CloseParenToken */, "[": 21 /* OpenBracketToken */, "]": 22 /* CloseBracketToken */, ".": 23 /* DotToken */, "...": 24 /* DotDotDotToken */, ";": 25 /* SemicolonToken */, ",": 26 /* CommaToken */, "<": 27 /* LessThanToken */, ">": 29 /* GreaterThanToken */, "<=": 30 /* LessThanEqualsToken */, ">=": 31 /* GreaterThanEqualsToken */, "==": 32 /* EqualsEqualsToken */, "!=": 33 /* ExclamationEqualsToken */, "===": 34 /* EqualsEqualsEqualsToken */, "!==": 35 /* ExclamationEqualsEqualsToken */, "=>": 36 /* EqualsGreaterThanToken */, "+": 37 /* PlusToken */, "-": 38 /* MinusToken */, "**": 40 /* AsteriskAsteriskToken */, "*": 39 /* AsteriskToken */, "/": 41 /* SlashToken */, "%": 42 /* PercentToken */, "++": 43 /* PlusPlusToken */, "--": 44 /* MinusMinusToken */, "<<": 45 /* LessThanLessThanToken */, ">": 46 /* GreaterThanGreaterThanToken */, ">>>": 47 /* GreaterThanGreaterThanGreaterThanToken */, "&": 48 /* AmpersandToken */, "|": 49 /* BarToken */, "^": 50 /* CaretToken */, "!": 51 /* ExclamationToken */, "~": 52 /* TildeToken */, "&&": 53 /* AmpersandAmpersandToken */, "||": 54 /* BarBarToken */, "?": 55 /* QuestionToken */, ":": 56 /* ColonToken */, "=": 58 /* EqualsToken */, "+=": 59 /* PlusEqualsToken */, "-=": 60 /* MinusEqualsToken */, "*=": 61 /* AsteriskEqualsToken */, "**=": 62 /* AsteriskAsteriskEqualsToken */, "/=": 63 /* SlashEqualsToken */, "%=": 64 /* PercentEqualsToken */, "<<=": 65 /* LessThanLessThanEqualsToken */, ">>=": 66 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 68 /* AmpersandEqualsToken */, "|=": 69 /* BarEqualsToken */, "^=": 70 /* CaretEqualsToken */, "@": 57 /* AtToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -7240,9 +7189,9 @@ var ts; if (len >= 2 && len <= 11) { var ch = tokenValue.charCodeAt(0); if (ch >= 97 /* a */ && ch <= 122 /* z */) { - token = textToToken.get(tokenValue); - if (token !== undefined) { - return token; + var keyword = textToKeyword.get(tokenValue); + if (keyword !== undefined) { + return token = keyword; } } } @@ -7922,7 +7871,7 @@ var ts; pos++; } tokenValue = text.substring(tokenPos, pos); - return token = 71 /* Identifier */; + return token = getIdentifierToken(); } else { return token = 0 /* Unknown */; @@ -21436,7 +21385,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(281 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -21631,7 +21580,7 @@ var ts; nextJSDocToken(); } } - function skipWhitespaceOrAsterisk(next) { + function skipWhitespaceOrAsterisk() { if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range @@ -21645,7 +21594,7 @@ var ts; else if (token() === 39 /* AsteriskToken */) { precedingLineBreak = false; } - next(); + nextJSDocToken(); } } function parseTag(indent) { @@ -21653,9 +21602,8 @@ var ts; var atToken = createNode(57 /* AtToken */, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); - // Use 'nextToken' instead of 'nextJsDocToken' so we can parse a type like 'number' in `@enum number` - var tagName = parseJSDocIdentifierName(/*message*/ undefined, nextToken); - skipWhitespaceOrAsterisk(nextToken); + var tagName = parseJSDocIdentifierName(/*message*/ undefined); + skipWhitespaceOrAsterisk(); var tag; switch (tagName.escapedText) { case "augments": @@ -21792,7 +21740,7 @@ var ts; tagsEnd = tag.end; } function tryParseTypeExpression() { - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); return token() === 17 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { @@ -21826,7 +21774,7 @@ var ts; function parseParameterOrPropertyTag(atToken, tagName, target, indent) { var typeExpression = tryParseTypeExpression(); var isNameFirst = !typeExpression; - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed; skipWhitespace(); if (isNameFirst) { @@ -21945,7 +21893,7 @@ var ts; } function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); var typedefTag = createNode(302 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; @@ -22178,8 +22126,7 @@ var ts; } return entity; } - function parseJSDocIdentifierName(message, next) { - if (next === void 0) { next = nextJSDocToken; } + function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { return createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } @@ -22188,7 +22135,7 @@ var ts; var result = createNode(71 /* Identifier */, pos); result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); finishNode(result, end); - next(); + nextJSDocToken(); return result; } } @@ -23674,30 +23621,6 @@ var ts; type: "object" }, description: ts.Diagnostics.List_of_language_service_plugins - }, - // extra options - { - name: "accessorOptimization", - type: "boolean" - }, - { - // this option can only be specified in tsconfig.json - // use type = object to copy the value as-is - name: "defines", - type: "object", - isTSConfigOnly: true - }, - { - name: "emitReflection", - type: "boolean" - }, - { - name: "noEmitJs", - type: "boolean" - }, - { - name: "reorderFiles", - type: "boolean" } ]); /* @internal */ @@ -23889,7 +23812,7 @@ var ts; i++; break; case "list": - var result = parseListTypeOption(opt, args[i], errors); + var result = parseListTypeOption(opt, args[i], errors); // tslint:disable-line no-unnecessary-type-assertion options[opt.name] = result || []; if (result) { i++; @@ -24011,8 +23934,7 @@ var ts; } /* @internal */ function printVersion() { - ts.sys.write("Version : " + ts.version_plus + ts.sys.newLine); - ts.sys.write("typescript-version : " + ts.version + ts.sys.newLine); + ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + ts.sys.newLine); } ts.printVersion = printVersion; /* @internal */ @@ -24424,7 +24346,7 @@ var ts; return undefined; } else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); // tslint:disable-line no-unnecessary-type-assertion } else { return optionDefinition.type; @@ -24487,7 +24409,7 @@ var ts; case "object": return {}; default: - return option.type.keys().next().value; + return option.type.keys().next().value; // tslint:disable-line no-unnecessary-type-assertion } } function makePadding(paddingLength) { @@ -24967,7 +24889,7 @@ var ts; if (isNullOrUndefined(value)) return undefined; if (option.type === "list") { - var listOption_1 = option; + var listOption_1 = option; // tslint:disable-line no-unnecessary-type-assertion if (listOption_1.element.isFilePath || !ts.isString(listOption_1.element.type)) { return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return !!v; }); } @@ -25311,7 +25233,7 @@ var ts; case "boolean": return typeof value === "boolean" ? value : ""; case "list": - var elementType_1 = option.element; + var elementType_1 = option.element; // tslint:disable-line no-unnecessary-type-assertion return ts.isArray(value) ? value.map(function (v) { return getOptionValueWithEmptyStrings(v, elementType_1); }) : ""; default: return ts.forEachEntry(option.type, function (optionEnumValue, optionStringValue) { @@ -56149,7 +56071,8 @@ var ts; return true; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 - if (target && ts.getModifierFlags(node) & 1 /* Export */ && target.flags & 67220415 /* Value */) { + if (target && ts.getModifierFlags(node) & 1 /* Export */ && + target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -69107,7 +69030,6 @@ var ts; var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); - var typeChecker = context.getEmitHost().getTypeChecker(); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; @@ -70040,13 +69962,7 @@ var ts; statements.push(transformSemicolonClassElementToStatement(member)); break; case 154 /* MethodDeclaration */: - var method = member; - if (method.isJumpTarget || (method.original && method.original.isJumpTarget)) { - transformJumpTarget(statements, getClassMemberPrefix(node, member), member); - } - else { - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); - } + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -70064,30 +69980,6 @@ var ts; } } } - function transformJumpTarget(statements, receiver, member) { - var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); - statements.push(ts.createStatement(ts.createAssignment(memberName, member.name))); - var sourceMapRange = ts.getSourceMapRange(member); - var memberFunction = transformMethodToFunctionDeclaration(member, /*location*/ member, /*name*/ member.name); - ts.setEmitFlags(memberFunction, 1536 /* NoComments */); - ts.setSourceMapRange(memberFunction, sourceMapRange); - statements.push(memberFunction); - } - function transformMethodToFunctionDeclaration(node, location, name) { - var savedConvertedLoopState = convertedLoopState; - convertedLoopState = undefined; - var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); - var parameters = ts.visitParameterList(node.parameters, visitor, context); - var body = transformFunctionBody(node); - exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); - convertedLoopState = savedConvertedLoopState; - return ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, node.asteriskToken, name, - /*typeParameters*/ undefined, parameters, - /*type*/ undefined, body), location), - /*original*/ node); - } /** * Transforms a SemicolonClassElement into a statement for a class body function. * @@ -70155,14 +70047,18 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterExpression = createAccessorExpression(getAccessor, firstAccessor, receiver, container); - var getter = ts.createPropertyAssignment("get", getterExpression); + var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); + ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); + ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); + var getter = ts.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); } if (setAccessor) { - var setterExpression = createAccessorExpression(setAccessor, firstAccessor, receiver, container); - var setter = ts.createPropertyAssignment("set", setterExpression); + var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); + ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); + ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); + var setter = ts.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } @@ -70180,75 +70076,6 @@ var ts; return call; } /** - * If the accessor method contains only one call to another method, use that method to define the accessor directly. - */ - function createAccessorExpression(accessor, firstAccessor, receiver, container) { - var expression; - var method = compilerOptions.accessorOptimization ? getJumpTargetOfAccessor(accessor) : null; - if (method) { - var methodName = ts.getMutableClone(method.name); - ts.setEmitFlags(methodName, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); - ts.setSourceMapRange(methodName, method.name); - if (firstAccessor.pos > method.pos) { // the target method has been already emitted. - var target = ts.getMutableClone(receiver); - ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); - ts.setSourceMapRange(target, firstAccessor.name); - expression = ts.createPropertyAccess(target, methodName); - } - else { - expression = methodName; - method.isJumpTarget = true; - } - } - else { - expression = transformFunctionLikeToExpression(accessor, /*location*/ undefined, /*name*/ undefined, container); - } - ts.setSourceMapRange(expression, ts.getSourceMapRange(accessor)); - ts.setEmitFlags(expression, 512 /* NoLeadingComments */); - return expression; - } - function getJumpTargetOfAccessor(accessor) { - if (accessor.body.statements.length != 1) { - return undefined; - } - var statement = accessor.body.statements[0]; - if (statement.kind !== 219 /* ExpressionStatement */ && - statement.kind !== 228 /* ReturnStatement */) { - return undefined; - } - var expression = statement.expression; - if (expression.kind !== 189 /* CallExpression */) { - return undefined; - } - var callExpression = expression; - if (accessor.kind === 157 /* SetAccessor */) { - if (callExpression.arguments.length != 1) { - return undefined; - } - var argument = callExpression.arguments[0]; - if (argument.kind !== 71 /* Identifier */) { - return undefined; - } - } - else { - if (callExpression.arguments.length != 0) { - return undefined; - } - } - if (callExpression.expression.kind !== 187 /* PropertyAccessExpression */) { - return undefined; - } - var propertyExpression = callExpression.expression; - if (propertyExpression.expression.kind !== 99 /* ThisKeyword */) { - return undefined; - } - var symbol = typeChecker.getSymbolAtLocation(propertyExpression.name); - if (!symbol) { - return undefined; - } - return ts.getDeclarationOfKind(symbol, 154 /* MethodDeclaration */); - } - /** * Visits an ArrowFunction and transforms it into a FunctionExpression. * * @param node An ArrowFunction node. @@ -79346,9 +79173,6 @@ var ts; var moduleKind = ts.getEmitModuleKind(compilerOptions); var transformers = []; ts.addRange(transformers, customTransformers && customTransformers.before); - if (compilerOptions.defines || compilerOptions.emitReflection) { - transformers.push(ts.transformTypeScriptPlus); - } transformers.push(ts.transformTypeScript); if (jsx === 2 /* React */) { transformers.push(ts.transformJsx); @@ -79645,976 +79469,6 @@ var ts; } ts.transformNodes = transformNodes; })(ts || (ts = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// The MIT License (MIT) -// -// Copyright (c) 2015-present, Dom Chen. -// All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in the -// Software without restriction, including without limitation the rights to use, copy, -// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, -// and to permit persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -////////////////////////////////////////////////////////////////////////////////////// -/*@internal*/ -var ts; -(function (ts) { - function transformTypeScriptPlus(context) { - var compilerOptions = context.getCompilerOptions(); - var compilerDefines = getCompilerDefines(compilerOptions.defines); - var typeChecker = compilerOptions.emitReflection || compilerDefines ? context.getEmitHost().getTypeChecker() : null; - var previousOnSubstituteNode = context.onSubstituteNode; - if (compilerDefines) { - context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(71 /* Identifier */); - } - return ts.chainBundle(transformSourceFile); - function transformSourceFile(node) { - if (!compilerOptions.emitReflection) { - return node; - } - var visited = ts.updateSourceFileNode(node, ts.visitNodes(node.statements, visitStatement, ts.isStatement)); - ts.addEmitHelpers(visited, context.readEmitHelpers()); - return visited; - } - function visitStatement(node) { - if (ts.hasModifier(node, 2 /* Ambient */)) { - return node; - } - if (node.kind === 238 /* ClassDeclaration */) { - return visitClassDeclaration(node); - } - if (node.kind === 242 /* ModuleDeclaration */) { - return visitModule(node); - } - return node; - } - function visitModule(node) { - if (node.body.kind === 242 /* ModuleDeclaration */) { - return updateModuleDeclaration(node, visitModule(node.body)); - } - if (node.body.kind === 243 /* ModuleBlock */) { - var body = updateModuleBlock(node.body, ts.visitNodes(node.body.statements, visitStatement, ts.isStatement)); - return updateModuleDeclaration(node, body); - } - return node; - } - function updateModuleDeclaration(node, body) { - if (node.body !== body) { - var updated = ts.getMutableClone(node); - updated.body = body; - return ts.updateNode(updated, node); - } - return node; - } - function updateModuleBlock(node, statements) { - if (node.statements !== statements) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements); - return ts.updateNode(updated, node); - } - return node; - } - function visitClassDeclaration(node) { - var classStatement = ts.getMutableClone(node); - var statements = [classStatement]; - var interfaceMap = {}; - getImplementedInterfaces(node, interfaceMap); - var allInterfaces = Object.keys(interfaceMap); - var interfaces; - var superTypes = getSuperClassTypes(node); - if (superTypes) { - interfaces = []; - for (var _i = 0, allInterfaces_1 = allInterfaces; _i < allInterfaces_1.length; _i++) { - var type = allInterfaces_1[_i]; - if (superTypes.indexOf(type) === -1) { - interfaces.push(type); - } - } - } - else { - interfaces = allInterfaces; - } - node.typeNames = interfaces; - var fullClassName = typeChecker.getFullyQualifiedName(node.symbol); - var expression = createReflectHelper(context, node.name, fullClassName, interfaces); - ts.setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); - var statement = ts.createStatement(expression); - ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); - statements.push(statement); - return statements; - } - function getImplementedInterfaces(node, result) { - var superInterfaces = undefined; - if (node.kind === 238 /* ClassDeclaration */) { - superInterfaces = ts.getClassImplementsHeritageClauseElements(node); - } - else { - superInterfaces = ts.getInterfaceBaseTypeNodes(node); - } - if (superInterfaces) { - superInterfaces.forEach(function (superInterface) { - var type = typeChecker.getTypeAtLocation(superInterface); - if (type && type.symbol && type.symbol.flags & 64 /* Interface */) { - var symbol = type.symbol; - var fullName = typeChecker.getFullyQualifiedName(symbol); - result[fullName] = true; - var declaration = ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); - if (declaration) { - getImplementedInterfaces(declaration, result); - } - } - }); - } - } - function getSuperClassTypes(node) { - var superClass = ts.getClassExtendsHeritageElement(node); - if (!superClass) { - return undefined; - } - var type = typeChecker.getTypeAtLocation(superClass); - if (!type || !type.symbol) { - return undefined; - } - var declaration = ts.getDeclarationOfKind(type.symbol, 238 /* ClassDeclaration */); - return declaration ? declaration.typeNames : undefined; - } - function getCompilerDefines(defines) { - if (!defines) { - return null; - } - var compilerDefines = {}; - var keys = Object.keys(defines); - for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { - var key = keys_1[_i]; - var value = defines[key]; - var type = typeof value; - switch (type) { - case "boolean": - case "number": - compilerDefines[key] = value.toString(); - break; - case "string": - compilerDefines[key] = "\"" + value + "\""; - break; - } - } - if (Object.keys(compilerDefines).length == 0) { - return null; - } - return compilerDefines; - } - function isDefinedConstant(node) { - var nodeText = ts.getTextOfIdentifierOrLiteral(node); - if (compilerDefines[nodeText] === undefined) { - return false; - } - if (!node.parent) { - return false; - } - if (node.parent.kind === 235 /* VariableDeclaration */ && node.parent.name === node) { - return false; - } - if (node.parent.kind === 202 /* BinaryExpression */) { - var parent = node.parent; - if (parent.left === node && parent.operatorToken.kind === 58 /* EqualsToken */) { - return false; - } - } - var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol || !symbol.declarations) { - return false; - } - var declaration = symbol.declarations[0]; - if (!declaration) { - return false; - } - if (declaration.kind !== 235 /* VariableDeclaration */) { - return false; - } - var statement = declaration.parent.parent; - return (statement.parent.kind === 277 /* SourceFile */); - } - /** - * Hooks node substitutions. - * @param emitContext The context for the emitter. - * @param node The node to substitute. - */ - function onSubstituteNode(hint, node) { - node = previousOnSubstituteNode(hint, node); - if (ts.isIdentifier(node) && isDefinedConstant(node)) { - var nodeText = ts.getTextOfIdentifierOrLiteral(node); - return ts.createIdentifier(compilerDefines[nodeText]); - } - return node; - } - } - ts.transformTypeScriptPlus = transformTypeScriptPlus; - var reflectHelper = { - name: "typescript:reflect", - scoped: false, - priority: 0, - text: "\n var __reflect = (this && this.__reflect) || function (p, c, t) {\n p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;\n };" - }; - function createReflectHelper(context, name, fullClassName, interfaces) { - context.requestEmitHelper(reflectHelper); - var argumentsArray = [ - ts.createPropertyAccess(name, ts.createIdentifier("prototype")), - ts.createLiteral(fullClassName) - ]; - if (interfaces.length) { - var elements = []; - for (var _i = 0, interfaces_1 = interfaces; _i < interfaces_1.length; _i++) { - var value = interfaces_1[_i]; - elements.push(ts.createLiteral(value)); - } - argumentsArray.push(ts.createArrayLiteral(elements)); - } - return ts.createCall(ts.getHelperName("__reflect"), - /*typeArguments*/ undefined, argumentsArray); - } -})(ts || (ts = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// The MIT License (MIT) -// -// Copyright (c) 2015-present, Dom Chen. -// All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in the -// Software without restriction, including without limitation the rights to use, copy, -// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, -// and to permit persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -////////////////////////////////////////////////////////////////////////////////////// -var ts; -(function (ts) { - var checker; - var sourceFiles; - var rootFileNames; - var dependencyMap; - var pathWeightMap; - var visitedBlocks; - var calledMethods = []; - function createMap() { - var map = Object.create(null); - // Using 'delete' on an object causes V8 to put the object in dictionary mode. - // This disables creation of hidden classes, which are expensive when an object is - // constantly changing shape. - map["__"] = undefined; - delete map["__"]; - return map; - } - function reorderSourceFiles(program) { - sourceFiles = program.getSourceFiles(); - rootFileNames = program.getRootFileNames(); - checker = program.getTypeChecker(); - visitedBlocks = []; - buildDependencyMap(); - var result = sortOnDependency(); - sourceFiles = []; - rootFileNames = []; - checker = null; - dependencyMap = null; - visitedBlocks = []; - return result; - } - ts.reorderSourceFiles = reorderSourceFiles; - function addDependency(file, dependent) { - if (file == dependent) { - return; - } - var list = dependencyMap[file]; - if (!list) { - list = dependencyMap[file] = []; - } - if (list.indexOf(dependent) == -1) { - list.push(dependent); - } - } - function buildDependencyMap() { - dependencyMap = createMap(); - for (var i = 0; i < sourceFiles.length; i++) { - var sourceFile = sourceFiles[i]; - if (sourceFile.isDeclarationFile) { - continue; - } - visitFile(sourceFile); - } - } - function visitFile(sourceFile) { - var statements = sourceFile.statements; - var length = statements.length; - for (var i = 0; i < length; i++) { - var statement = statements[i]; - if (ts.hasModifier(statement, 2 /* Ambient */)) { // has the 'declare' keyword - continue; - } - visitStatement(statements[i]); - } - } - function visitStatement(statement) { - if (!statement) { - return; - } - switch (statement.kind) { - case 219 /* ExpressionStatement */: - var expression = statement; - visitExpression(expression.expression); - break; - case 238 /* ClassDeclaration */: - checkInheriting(statement); - visitStaticMember(statement); - if (statement.transformFlags & 4096 /* ContainsDecorators */) { - visitClassDecorators(statement); - } - break; - case 217 /* VariableStatement */: - visitVariableList(statement.declarationList); - break; - case 246 /* ImportEqualsDeclaration */: - var importDeclaration = statement; - checkDependencyAtLocation(importDeclaration.moduleReference); - break; - case 242 /* ModuleDeclaration */: - visitModule(statement); - break; - case 216 /* Block */: - visitBlock(statement); - break; - case 220 /* IfStatement */: - var ifStatement = statement; - visitExpression(ifStatement.expression); - visitStatement(ifStatement.thenStatement); - visitStatement(ifStatement.elseStatement); - break; - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - var doStatement = statement; - visitExpression(doStatement.expression); - visitStatement(doStatement.statement); - break; - case 223 /* ForStatement */: - var forStatement = statement; - visitExpression(forStatement.condition); - visitExpression(forStatement.incrementor); - if (forStatement.initializer) { - if (forStatement.initializer.kind === 236 /* VariableDeclarationList */) { - visitVariableList(forStatement.initializer); - } - else { - visitExpression(forStatement.initializer); - } - } - break; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - var forInStatement = statement; - visitExpression(forInStatement.expression); - if (forInStatement.initializer) { - if (forInStatement.initializer.kind === 236 /* VariableDeclarationList */) { - visitVariableList(forInStatement.initializer); - } - else { - visitExpression(forInStatement.initializer); - } - } - break; - case 228 /* ReturnStatement */: - visitExpression(statement.expression); - break; - case 230 /* SwitchStatement */: - var switchStatment = statement; - visitExpression(switchStatment.expression); - switchStatment.caseBlock.clauses.forEach(function (element) { - if (element.kind === 269 /* CaseClause */) { - visitExpression(element.expression); - } - element.statements.forEach(function (element) { - visitStatement(element); - }); - }); - break; - case 231 /* LabeledStatement */: - visitStatement(statement.statement); - break; - case 232 /* ThrowStatement */: - visitExpression(statement.expression); - break; - case 233 /* TryStatement */: - var tryStatement = statement; - visitBlock(tryStatement.tryBlock); - visitBlock(tryStatement.finallyBlock); - if (tryStatement.catchClause) { - visitBlock(tryStatement.catchClause.block); - } - break; - } - } - function visitModule(node) { - if (node.body.kind === 242 /* ModuleDeclaration */) { - visitModule(node.body); - return; - } - if (node.body.kind === 243 /* ModuleBlock */) { - for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (ts.hasModifier(statement, 2 /* Ambient */)) { // has the 'declare' keyword - continue; - } - visitStatement(statement); - } - } - } - function checkDependencyAtLocation(node) { - var symbol = checker.getSymbolAtLocation(node); - if (!symbol || !symbol.declarations) { - return; - } - var sourceFile = getSourceFileOfNode(symbol.declarations[0]); - if (!sourceFile || sourceFile.isDeclarationFile) { - return; - } - addDependency(getSourceFileOfNode(node).fileName, sourceFile.fileName); - } - function checkInheriting(node) { - if (!node.heritageClauses) { - return; - } - var heritageClause = null; - for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { - var clause = _a[_i]; - if (clause.token === 85 /* ExtendsKeyword */) { - heritageClause = clause; - break; - } - } - if (!heritageClause) { - return; - } - var superClasses = heritageClause.types; - if (!superClasses) { - return; - } - superClasses.forEach(function (superClass) { - checkDependencyAtLocation(superClass.expression); - }); - } - function visitStaticMember(node) { - var members = node.members; - if (!members) { - return; - } - for (var _i = 0, members_6 = members; _i < members_6.length; _i++) { - var member = members_6[_i]; - if (!ts.hasModifier(member, 32 /* Static */)) { - continue; - } - if (member.kind == 152 /* PropertyDeclaration */) { - var property = member; - visitExpression(property.initializer); - } - } - } - function visitClassDecorators(node) { - if (node.decorators) { - visitDecorators(node.decorators); - } - var members = node.members; - if (!members) { - return; - } - for (var _i = 0, members_7 = members; _i < members_7.length; _i++) { - var member = members_7[_i]; - var decorators = void 0; - var functionLikeMember = void 0; - if (member.kind === 156 /* GetAccessor */ || member.kind === 157 /* SetAccessor */) { - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member !== accessors.firstAccessor) { - continue; - } - decorators = accessors.firstAccessor.decorators; - if (!decorators && accessors.secondAccessor) { - decorators = accessors.secondAccessor.decorators; - } - functionLikeMember = accessors.setAccessor; - } - else { - decorators = member.decorators; - if (member.kind === 154 /* MethodDeclaration */) { - functionLikeMember = member; - } - } - if (decorators) { - visitDecorators(decorators); - } - if (functionLikeMember) { - for (var _a = 0, _b = functionLikeMember.parameters; _a < _b.length; _a++) { - var parameter = _b[_a]; - if (parameter.decorators) { - visitDecorators(parameter.decorators); - } - } - } - } - } - function visitDecorators(decorators) { - for (var _i = 0, decorators_2 = decorators; _i < decorators_2.length; _i++) { - var decorator = decorators_2[_i]; - visitCallExpression(decorator.expression); - } - } - function visitExpression(expression) { - if (!expression) { - return; - } - switch (expression.kind) { - case 190 /* NewExpression */: - case 189 /* CallExpression */: - visitCallArguments(expression); - visitCallExpression(expression.expression); - break; - case 71 /* Identifier */: - checkDependencyAtLocation(expression); - break; - case 187 /* PropertyAccessExpression */: - checkDependencyAtLocation(expression); - break; - case 188 /* ElementAccessExpression */: - visitExpression(expression.expression); - break; - case 186 /* ObjectLiteralExpression */: - visitObjectLiteralExpression(expression); - break; - case 185 /* ArrayLiteralExpression */: - var arrayLiteral = expression; - arrayLiteral.elements.forEach(visitExpression); - break; - case 204 /* TemplateExpression */: - var template = expression; - template.templateSpans.forEach(function (span) { - visitExpression(span.expression); - }); - break; - case 193 /* ParenthesizedExpression */: - var parenthesized = expression; - visitExpression(parenthesized.expression); - break; - case 202 /* BinaryExpression */: - visitBinaryExpression(expression); - break; - case 201 /* PostfixUnaryExpression */: - case 200 /* PrefixUnaryExpression */: - visitExpression(expression.operand); - break; - case 196 /* DeleteExpression */: - visitExpression(expression.expression); - break; - case 191 /* TaggedTemplateExpression */: - visitExpression(expression.tag); - visitExpression(expression.template); - break; - case 203 /* ConditionalExpression */: - visitExpression(expression.condition); - visitExpression(expression.whenTrue); - visitExpression(expression.whenFalse); - break; - case 206 /* SpreadElement */: - visitExpression(expression.expression); - break; - case 198 /* VoidExpression */: - visitExpression(expression.expression); - break; - case 205 /* YieldExpression */: - visitExpression(expression.expression); - break; - case 199 /* AwaitExpression */: - visitExpression(expression.expression); - break; - case 197 /* TypeOfExpression */: - visitExpression(expression.expression); - break; - case 211 /* NonNullExpression */: - visitExpression(expression.expression); - break; - case 192 /* TypeAssertionExpression */: - visitExpression(expression.expression); - break; - } - // FunctionExpression - // ArrowFunction - // ClassExpression - // OmittedExpression - // ExpressionWithTypeArguments - // AsExpression - } - function visitBinaryExpression(binary) { - var left = binary.left; - var right = binary.right; - visitExpression(left); - visitExpression(right); - if (binary.operatorToken.kind === 58 /* EqualsToken */ && - (left.kind === 71 /* Identifier */ || left.kind === 187 /* PropertyAccessExpression */) && - (right.kind === 71 /* Identifier */ || right.kind === 187 /* PropertyAccessExpression */)) { - var symbol = checker.getSymbolAtLocation(left); - if (!symbol || !symbol.declarations) { - return; - } - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 235 /* VariableDeclaration */ || declaration.kind === 152 /* PropertyDeclaration */) { - var variable = declaration; - if (variable.initializer) { - continue; - } - if (!variable.delayInitializerList) { - variable.delayInitializerList = []; - } - variable.delayInitializerList.push(right); - if (variable.callerList) { - for (var _b = 0, _c = variable.callerList; _b < _c.length; _b++) { - var callerFileName = _c[_b]; - checkCallTarget(callerFileName, right); - } - } - } - } - } - } - function visitObjectLiteralExpression(objectLiteral) { - objectLiteral.properties.forEach(function (element) { - switch (element.kind) { - case 273 /* PropertyAssignment */: - visitExpression(element.initializer); - break; - case 274 /* ShorthandPropertyAssignment */: - visitExpression(element.objectAssignmentInitializer); - break; - case 275 /* SpreadAssignment */: - visitExpression(element.expression); - break; - } - }); - } - function visitCallArguments(callExpression) { - if (callExpression.arguments) { - callExpression.arguments.forEach(function (argument) { - visitExpression(argument); - }); - } - } - function visitCallExpression(expression) { - expression = escapeParenthesized(expression); - visitExpression(expression); - switch (expression.kind) { - case 194 /* FunctionExpression */: - var functionExpression = expression; - visitBlock(functionExpression.body); - break; - case 187 /* PropertyAccessExpression */: - case 71 /* Identifier */: - var callerFileName = getSourceFileOfNode(expression).fileName; - checkCallTarget(callerFileName, expression); - break; - case 189 /* CallExpression */: - visitReturnedFunction(expression.expression); - break; - } - } - function visitReturnedFunction(expression) { - expression = escapeParenthesized(expression); - var returnExpressions = []; - if (expression.kind === 189 /* CallExpression */) { - var expressions = visitReturnedFunction(expression.expression); - for (var _i = 0, expressions_2 = expressions; _i < expressions_2.length; _i++) { - var returnExpression = expressions_2[_i]; - var returns = visitReturnedFunction(returnExpression); - returnExpressions = returnExpressions.concat(returns); - } - return returnExpressions; - } - var functionBlocks = []; - switch (expression.kind) { - case 194 /* FunctionExpression */: - functionBlocks.push(expression.body); - break; - case 187 /* PropertyAccessExpression */: - case 71 /* Identifier */: - var callerFileName = getSourceFileOfNode(expression).fileName; - var declarations = []; - getForwardDeclarations(expression, declarations, callerFileName); - for (var _a = 0, declarations_11 = declarations; _a < declarations_11.length; _a++) { - var declaration = declarations_11[_a]; - var sourceFile = getSourceFileOfNode(declaration); - if (!sourceFile || sourceFile.isDeclarationFile) { - continue; - } - if (declaration.kind === 237 /* FunctionDeclaration */ || - declaration.kind === 154 /* MethodDeclaration */) { - functionBlocks.push(declaration.body); - } - } - break; - } - for (var _b = 0, functionBlocks_1 = functionBlocks; _b < functionBlocks_1.length; _b++) { - var block = functionBlocks_1[_b]; - for (var _c = 0, _d = block.statements; _c < _d.length; _c++) { - var statement = _d[_c]; - if (statement.kind === 228 /* ReturnStatement */) { - var returnExpression = statement.expression; - returnExpressions.push(returnExpression); - visitCallExpression(returnExpression); - } - } - } - return returnExpressions; - } - function escapeParenthesized(expression) { - if (expression.kind === 193 /* ParenthesizedExpression */) { - return escapeParenthesized(expression.expression); - } - return expression; - } - function checkCallTarget(callerFileName, target) { - var declarations = []; - getForwardDeclarations(target, declarations, callerFileName); - for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { - var declaration = declarations_12[_i]; - var sourceFile = getSourceFileOfNode(declaration); - if (!sourceFile || sourceFile.isDeclarationFile) { - continue; - } - addDependency(callerFileName, sourceFile.fileName); - if (declaration.kind === 237 /* FunctionDeclaration */) { - visitBlock(declaration.body); - } - else if (declaration.kind === 154 /* MethodDeclaration */) { - visitBlock(declaration.body); - calledMethods.push(declaration); - } - else if (declaration.kind === 238 /* ClassDeclaration */) { - checkClassInstantiation(declaration); - } - } - } - function getForwardDeclarations(reference, declarations, callerFileName) { - var symbol = checker.getSymbolAtLocation(reference); - if (!symbol || !symbol.declarations) { - return; - } - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - switch (declaration.kind) { - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 238 /* ClassDeclaration */: - if (declarations.indexOf(declaration) == -1) { - declarations.push(declaration); - } - break; - case 246 /* ImportEqualsDeclaration */: - getForwardDeclarations(declaration.moduleReference, declarations, callerFileName); - break; - case 235 /* VariableDeclaration */: - case 152 /* PropertyDeclaration */: - var variable = declaration; - var initializer = variable.initializer; - if (initializer) { - if (initializer.kind === 71 /* Identifier */ || initializer.kind === 187 /* PropertyAccessExpression */) { - getForwardDeclarations(initializer, declarations, callerFileName); - } - } - else { - if (variable.delayInitializerList) { - for (var _b = 0, _c = variable.delayInitializerList; _b < _c.length; _b++) { - var expression = _c[_b]; - getForwardDeclarations(expression, declarations, callerFileName); - } - } - if (variable.callerList) { - if (variable.callerList.indexOf(callerFileName) == -1) { - variable.callerList.push(callerFileName); - } - } - else { - variable.callerList = [callerFileName]; - } - } - break; - } - } - } - function checkClassInstantiation(node) { - var methodNames = []; - var superClass = ts.getClassExtendsHeritageElement(node); - if (superClass) { - var type = checker.getTypeAtLocation(superClass); - if (type && type.symbol) { - var declaration = ts.getDeclarationOfKind(type.symbol, 238 /* ClassDeclaration */); - if (declaration) { - methodNames = checkClassInstantiation(declaration); - } - } - } - var members = node.members; - if (!members) { - return []; - } - var index = calledMethods.length; - for (var _i = 0, members_8 = members; _i < members_8.length; _i++) { - var member = members_8[_i]; - if (ts.hasModifier(member, 32 /* Static */)) { - continue; - } - if (member.kind === 154 /* MethodDeclaration */) { // called by super class. - var methodName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name)); - if (methodNames.indexOf(methodName) != -1) { - visitBlock(member.body); - } - } - if (member.kind === 152 /* PropertyDeclaration */) { - var property = member; - visitExpression(property.initializer); - } - else if (member.kind === 155 /* Constructor */) { - var constructor = member; - visitBlock(constructor.body); - } - } - for (var i = index; i < calledMethods.length; i++) { - var method = calledMethods[i]; - for (var _a = 0, members_9 = members; _a < members_9.length; _a++) { - var memeber = members_9[_a]; - if (memeber === method) { - var methodName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(method.name)); - methodNames.push(methodName); - } - } - } - if (index == 0) { - calledMethods.length = 0; - } - return methodNames; - } - function visitBlock(block) { - if (!block || visitedBlocks.indexOf(block) != -1) { - return; - } - visitedBlocks.push(block); - for (var _i = 0, _a = block.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - visitStatement(statement); - } - visitedBlocks.pop(); - } - function visitVariableList(variables) { - if (!variables) { - return; - } - variables.declarations.forEach(function (declaration) { - visitExpression(declaration.initializer); - }); - } - function sortOnDependency() { - var result = {}; - result.sortedFileNames = []; - result.circularReferences = []; - pathWeightMap = createMap(); - var dtsFiles = []; - var tsFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var path = sourceFile.fileName; - if (sourceFile.isDeclarationFile) { - pathWeightMap[path] = 10000; - dtsFiles.push(sourceFile); - continue; - } - var references = updatePathWeight(path, 0, [path]); - if (references.length > 0) { - result.circularReferences = references; - break; - } - tsFiles.push(sourceFile); - } - if (result.circularReferences.length === 0) { - tsFiles.sort(function (a, b) { - return pathWeightMap[b.fileName] - pathWeightMap[a.fileName]; - }); - sourceFiles.length = 0; - rootFileNames.length = 0; - dtsFiles.concat(tsFiles).forEach(function (sourceFile) { - sourceFiles.push(sourceFile); - rootFileNames.push(sourceFile.fileName); - result.sortedFileNames.push(sourceFile.fileName); - }); - } - pathWeightMap = null; - return result; - } - function updatePathWeight(path, weight, references) { - if (pathWeightMap[path] === undefined) { - pathWeightMap[path] = weight; - } - else { - if (pathWeightMap[path] < weight) { - pathWeightMap[path] = weight; - } - else { - return []; - } - } - var list = dependencyMap[path]; - if (!list) { - return []; - } - for (var _i = 0, list_3 = list; _i < list_3.length; _i++) { - var parentPath = list_3[_i]; - if (references.indexOf(parentPath) != -1) { - references.push(parentPath); - return references; - } - var result = updatePathWeight(parentPath, weight + 1, references.concat(parentPath)); - if (result.length > 0) { - return result; - } - } - return []; - } - function getSourceFileOfNode(node) { - while (node && node.kind !== 277 /* SourceFile */) { - node = node.parent; - } - return node; - } -})(ts || (ts = {})); /* @internal */ var ts; (function (ts) { @@ -81458,8 +80312,8 @@ var ts; } } else { - for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { - var sourceFile = sourceFiles_2[_a]; + for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { + var sourceFile = sourceFiles_1[_a]; var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); if (result) { return result; @@ -86130,7 +84984,7 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - 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, getTypeChecker: program.getTypeChecker, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + 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, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches var path = toPath(f); if (getSourceFileByPath(path)) @@ -87076,8 +85930,8 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var sourceFile = sourceFiles_2[_i]; if (!sourceFile.isDeclarationFile) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { diff --git a/package.json b/package.json index 55ac17e32..adec5f095 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { - "name": "typescript-plus", - "author": "Dom Chen", - "homepage": "http://www.idom.me/", + "name": "typescript", + "author": "Microsoft Corp.", + "homepage": "http://typescriptlang.org/", "version": "3.1.5", - "license": "Apache-2.0", - "description": "An enhanced version of the original typescript compiler.", + "license": "Apache-2.0", + "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ "TypeScript", "Microsoft", @@ -13,21 +13,22 @@ "javascript" ], "bugs": { - "url": "https://github.com/domchen/typescript-plus/issues" + "url": "https://github.com/Microsoft/TypeScript/issues" }, "repository": { "type": "git", - "url": "https://github.com/domchen/typescript-plus.git" + "url": "https://github.com/Microsoft/TypeScript.git" }, "main": "./lib/typescript.js", "typings": "./lib/typescript.d.ts", "bin": { - "tsc-plus": "./bin/tsc" + "tsc": "./bin/tsc", + "tsserver": "./bin/tsserver" }, "engines": { "node": ">=4.2.0" }, - "devDependencies": { + "devDependencies": { "@octokit/rest": "latest", "@types/browserify": "latest", "@types/chai": "latest", @@ -113,4 +114,4 @@ "path": false }, "dependencies": {} -} +} \ No newline at end of file diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2b98d80a7..0c5807f75 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -28274,7 +28274,8 @@ namespace ts { return true; } const target = getSymbolLinks(symbol!).target; // TODO: GH#18217 - if (target && getModifierFlags(node) & ModifierFlags.Export && target.flags & SymbolFlags.Value) { + if (target && getModifierFlags(node) & ModifierFlags.Export && + target.flags & SymbolFlags.Value && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index b3f9fb69f..ee1b83f73 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -782,32 +782,7 @@ namespace ts { type: "object" }, description: Diagnostics.List_of_language_service_plugins - }, - // extra options - { - name: "accessorOptimization", - type: "boolean" - }, - { - // this option can only be specified in tsconfig.json - // use type = object to copy the value as-is - name: "defines", - type: "object", - isTSConfigOnly: true - }, - { - name: "emitReflection", - type: "boolean" - }, - { - name: "noEmitJs", - type: "boolean" - }, - { - name: "reorderFiles", - type: "boolean" } - ]; /* @internal */ @@ -1030,7 +1005,7 @@ namespace ts { i++; break; case "list": - const result = parseListTypeOption(opt, args[i], errors); + const result = parseListTypeOption(opt, args[i], errors); // tslint:disable-line no-unnecessary-type-assertion options[opt.name] = result || []; if (result) { i++; @@ -1159,8 +1134,7 @@ namespace ts { /* @internal */ export function printVersion() { - sys.write("Version : " + ts.version_plus + sys.newLine); - sys.write("typescript-version : " + ts.version + sys.newLine); + sys.write(getDiagnosticText(Diagnostics.Version_0, version) + sys.newLine); } /* @internal */ @@ -1680,7 +1654,7 @@ namespace ts { return undefined; } else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption((optionDefinition).element); + return getCustomTypeMapOfCommandLineOption((optionDefinition).element); // tslint:disable-line no-unnecessary-type-assertion } else { return (optionDefinition).type; @@ -1744,7 +1718,7 @@ namespace ts { case "object": return {}; default: - return (option as CommandLineOptionOfCustomType).type.keys().next().value; + return (option as CommandLineOptionOfCustomType).type.keys().next().value; // tslint:disable-line no-unnecessary-type-assertion } } @@ -2331,7 +2305,7 @@ namespace ts { function normalizeOptionValue(option: CommandLineOption, basePath: string, value: any): CompilerOptionsValue { if (isNullOrUndefined(value)) return undefined; if (option.type === "list") { - const listOption = option; + const listOption = option; // tslint:disable-line no-unnecessary-type-assertion if (listOption.element.isFilePath || !isString(listOption.element.type)) { return filter(map(value, v => normalizeOptionValue(listOption.element, basePath, v)), v => !!v); } @@ -2716,7 +2690,7 @@ namespace ts { case "boolean": return typeof value === "boolean" ? value : ""; case "list": - const elementType = (option as CommandLineOptionOfListType).element; + const elementType = (option as CommandLineOptionOfListType).element; // tslint:disable-line no-unnecessary-type-assertion return isArray(value) ? value.map(v => getOptionValueWithEmptyStrings(v, elementType)) : ""; default: return forEachEntry(option.type, (optionEnumValue, optionStringValue) => { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 7b59a2d96..271bad761 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -3,8 +3,7 @@ namespace ts { // If changing the text in this section, be sure to test `configureNightly` too. export const versionMajorMinor = "3.1"; /** The version of the TypeScript compiler release */ - export const version = `${versionMajorMinor}.3`; - export const version_plus = "3.1.5"; + export const version = `${versionMajorMinor}.5`; } namespace ts { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 33829fccb..d2ae81cca 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -6308,7 +6308,7 @@ namespace ts { // Parses out a JSDoc type expression. export function parseJSDocTypeExpression(mayOmitBraces?: boolean): JSDocTypeExpression { - const result = createNode(SyntaxKind.JSDocTypeExpression, scanner.getTokenPos()); + const result = createNode(SyntaxKind.JSDocTypeExpression); const hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(SyntaxKind.OpenBraceToken); result.type = doInsideOfContext(NodeFlags.JSDoc, parseJSDocType); @@ -6517,7 +6517,7 @@ namespace ts { } } - function skipWhitespaceOrAsterisk(next: () => void): void { + function skipWhitespaceOrAsterisk(): void { if (token() === SyntaxKind.WhitespaceTrivia || token() === SyntaxKind.NewLineTrivia) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range @@ -6532,7 +6532,7 @@ namespace ts { else if (token() === SyntaxKind.AsteriskToken) { precedingLineBreak = false; } - next(); + nextJSDocToken(); } } @@ -6542,9 +6542,8 @@ namespace ts { atToken.end = scanner.getTextPos(); nextJSDocToken(); - // Use 'nextToken' instead of 'nextJsDocToken' so we can parse a type like 'number' in `@enum number` - const tagName = parseJSDocIdentifierName(/*message*/ undefined, nextToken); - skipWhitespaceOrAsterisk(nextToken); + const tagName = parseJSDocIdentifierName(/*message*/ undefined); + skipWhitespaceOrAsterisk(); let tag: JSDocTag | undefined; switch (tagName.escapedText) { @@ -6688,7 +6687,7 @@ namespace ts { } function tryParseTypeExpression(): JSDocTypeExpression | undefined { - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); return token() === SyntaxKind.OpenBraceToken ? parseJSDocTypeExpression() : undefined; } @@ -6728,7 +6727,7 @@ namespace ts { function parseParameterOrPropertyTag(atToken: AtToken, tagName: Identifier, target: PropertyLikeParse, indent: number): JSDocParameterTag | JSDocPropertyTag { let typeExpression = tryParseTypeExpression(); let isNameFirst = !typeExpression; - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); const { name, isBracketed } = parseBracketNameInPropertyAndParamTag(); skipWhitespace(); @@ -6862,7 +6861,7 @@ namespace ts { function parseTypedefTag(atToken: AtToken, tagName: Identifier, indent: number): JSDocTypedefTag { const typeExpression = tryParseTypeExpression(); - skipWhitespaceOrAsterisk(nextJSDocToken); + skipWhitespaceOrAsterisk(); const typedefTag = createNode(SyntaxKind.JSDocTypedefTag, atToken.pos); typedefTag.atToken = atToken; @@ -7115,7 +7114,7 @@ namespace ts { return entity; } - function parseJSDocIdentifierName(message?: DiagnosticMessage, next: () => void = nextJSDocToken): Identifier { + function parseJSDocIdentifierName(message?: DiagnosticMessage): Identifier { if (!tokenIsIdentifierOrKeyword(token())) { return createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ !message, message || Diagnostics.Identifier_expected); } @@ -7126,7 +7125,7 @@ namespace ts { result.escapedText = escapeLeadingUnderscores(scanner.getTokenText()); finishNode(result, end); - next(); + nextJSDocToken(); return result; } } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index afa2286fe..44eae36d6 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1274,7 +1274,6 @@ namespace ts { getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, - getTypeChecker: program.getTypeChecker, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary, writeFile: writeFileCallback || ( diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index b339220c3..1a5c4336b 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -60,81 +60,87 @@ namespace ts { tryScan(callback: () => T): T; } - const textToToken = createMapFromTemplate({ - "abstract": SyntaxKind.AbstractKeyword, - "any": SyntaxKind.AnyKeyword, - "as": SyntaxKind.AsKeyword, - "boolean": SyntaxKind.BooleanKeyword, - "break": SyntaxKind.BreakKeyword, - "case": SyntaxKind.CaseKeyword, - "catch": SyntaxKind.CatchKeyword, - "class": SyntaxKind.ClassKeyword, - "continue": SyntaxKind.ContinueKeyword, - "const": SyntaxKind.ConstKeyword, - "constructor": SyntaxKind.ConstructorKeyword, - "debugger": SyntaxKind.DebuggerKeyword, - "declare": SyntaxKind.DeclareKeyword, - "default": SyntaxKind.DefaultKeyword, - "delete": SyntaxKind.DeleteKeyword, - "do": SyntaxKind.DoKeyword, - "else": SyntaxKind.ElseKeyword, - "enum": SyntaxKind.EnumKeyword, - "export": SyntaxKind.ExportKeyword, - "extends": SyntaxKind.ExtendsKeyword, - "false": SyntaxKind.FalseKeyword, - "finally": SyntaxKind.FinallyKeyword, - "for": SyntaxKind.ForKeyword, - "from": SyntaxKind.FromKeyword, - "function": SyntaxKind.FunctionKeyword, - "get": SyntaxKind.GetKeyword, - "if": SyntaxKind.IfKeyword, - "implements": SyntaxKind.ImplementsKeyword, - "import": SyntaxKind.ImportKeyword, - "in": SyntaxKind.InKeyword, - "infer": SyntaxKind.InferKeyword, - "instanceof": SyntaxKind.InstanceOfKeyword, - "interface": SyntaxKind.InterfaceKeyword, - "is": SyntaxKind.IsKeyword, - "keyof": SyntaxKind.KeyOfKeyword, - "let": SyntaxKind.LetKeyword, - "module": SyntaxKind.ModuleKeyword, - "namespace": SyntaxKind.NamespaceKeyword, - "never": SyntaxKind.NeverKeyword, - "new": SyntaxKind.NewKeyword, - "null": SyntaxKind.NullKeyword, - "number": SyntaxKind.NumberKeyword, - "object": SyntaxKind.ObjectKeyword, - "package": SyntaxKind.PackageKeyword, - "private": SyntaxKind.PrivateKeyword, - "protected": SyntaxKind.ProtectedKeyword, - "public": SyntaxKind.PublicKeyword, - "readonly": SyntaxKind.ReadonlyKeyword, - "require": SyntaxKind.RequireKeyword, - "global": SyntaxKind.GlobalKeyword, - "return": SyntaxKind.ReturnKeyword, - "set": SyntaxKind.SetKeyword, - "static": SyntaxKind.StaticKeyword, - "string": SyntaxKind.StringKeyword, - "super": SyntaxKind.SuperKeyword, - "switch": SyntaxKind.SwitchKeyword, - "symbol": SyntaxKind.SymbolKeyword, - "this": SyntaxKind.ThisKeyword, - "throw": SyntaxKind.ThrowKeyword, - "true": SyntaxKind.TrueKeyword, - "try": SyntaxKind.TryKeyword, - "type": SyntaxKind.TypeKeyword, - "typeof": SyntaxKind.TypeOfKeyword, - "undefined": SyntaxKind.UndefinedKeyword, - "unique": SyntaxKind.UniqueKeyword, - "unknown": SyntaxKind.UnknownKeyword, - "var": SyntaxKind.VarKeyword, - "void": SyntaxKind.VoidKeyword, - "while": SyntaxKind.WhileKeyword, - "with": SyntaxKind.WithKeyword, - "yield": SyntaxKind.YieldKeyword, - "async": SyntaxKind.AsyncKeyword, - "await": SyntaxKind.AwaitKeyword, - "of": SyntaxKind.OfKeyword, + const textToKeywordObj: MapLike = { + abstract: SyntaxKind.AbstractKeyword, + any: SyntaxKind.AnyKeyword, + as: SyntaxKind.AsKeyword, + boolean: SyntaxKind.BooleanKeyword, + break: SyntaxKind.BreakKeyword, + case: SyntaxKind.CaseKeyword, + catch: SyntaxKind.CatchKeyword, + class: SyntaxKind.ClassKeyword, + continue: SyntaxKind.ContinueKeyword, + const: SyntaxKind.ConstKeyword, + ["" + "constructor"]: SyntaxKind.ConstructorKeyword, + debugger: SyntaxKind.DebuggerKeyword, + declare: SyntaxKind.DeclareKeyword, + default: SyntaxKind.DefaultKeyword, + delete: SyntaxKind.DeleteKeyword, + do: SyntaxKind.DoKeyword, + else: SyntaxKind.ElseKeyword, + enum: SyntaxKind.EnumKeyword, + export: SyntaxKind.ExportKeyword, + extends: SyntaxKind.ExtendsKeyword, + false: SyntaxKind.FalseKeyword, + finally: SyntaxKind.FinallyKeyword, + for: SyntaxKind.ForKeyword, + from: SyntaxKind.FromKeyword, + function: SyntaxKind.FunctionKeyword, + get: SyntaxKind.GetKeyword, + if: SyntaxKind.IfKeyword, + implements: SyntaxKind.ImplementsKeyword, + import: SyntaxKind.ImportKeyword, + in: SyntaxKind.InKeyword, + infer: SyntaxKind.InferKeyword, + instanceof: SyntaxKind.InstanceOfKeyword, + interface: SyntaxKind.InterfaceKeyword, + is: SyntaxKind.IsKeyword, + keyof: SyntaxKind.KeyOfKeyword, + let: SyntaxKind.LetKeyword, + module: SyntaxKind.ModuleKeyword, + namespace: SyntaxKind.NamespaceKeyword, + never: SyntaxKind.NeverKeyword, + new: SyntaxKind.NewKeyword, + null: SyntaxKind.NullKeyword, + number: SyntaxKind.NumberKeyword, + object: SyntaxKind.ObjectKeyword, + package: SyntaxKind.PackageKeyword, + private: SyntaxKind.PrivateKeyword, + protected: SyntaxKind.ProtectedKeyword, + public: SyntaxKind.PublicKeyword, + readonly: SyntaxKind.ReadonlyKeyword, + require: SyntaxKind.RequireKeyword, + global: SyntaxKind.GlobalKeyword, + return: SyntaxKind.ReturnKeyword, + set: SyntaxKind.SetKeyword, + static: SyntaxKind.StaticKeyword, + string: SyntaxKind.StringKeyword, + super: SyntaxKind.SuperKeyword, + switch: SyntaxKind.SwitchKeyword, + symbol: SyntaxKind.SymbolKeyword, + this: SyntaxKind.ThisKeyword, + throw: SyntaxKind.ThrowKeyword, + true: SyntaxKind.TrueKeyword, + try: SyntaxKind.TryKeyword, + type: SyntaxKind.TypeKeyword, + typeof: SyntaxKind.TypeOfKeyword, + undefined: SyntaxKind.UndefinedKeyword, + unique: SyntaxKind.UniqueKeyword, + unknown: SyntaxKind.UnknownKeyword, + var: SyntaxKind.VarKeyword, + void: SyntaxKind.VoidKeyword, + while: SyntaxKind.WhileKeyword, + with: SyntaxKind.WithKeyword, + yield: SyntaxKind.YieldKeyword, + async: SyntaxKind.AsyncKeyword, + await: SyntaxKind.AwaitKeyword, + of: SyntaxKind.OfKeyword, + }; + + const textToKeyword = createMapFromTemplate(textToKeywordObj); + + const textToToken = createMapFromTemplate({ + ...textToKeywordObj, "{": SyntaxKind.OpenBraceToken, "}": SyntaxKind.CloseBraceToken, "(": SyntaxKind.OpenParenToken, @@ -1288,15 +1294,15 @@ namespace ts { return result; } - function getIdentifierToken(): SyntaxKind { + function getIdentifierToken(): SyntaxKind.Identifier | KeywordSyntaxKind { // Reserved words are between 2 and 11 characters long and start with a lowercase letter const len = tokenValue.length; if (len >= 2 && len <= 11) { const ch = tokenValue.charCodeAt(0); if (ch >= CharacterCodes.a && ch <= CharacterCodes.z) { - token = textToToken.get(tokenValue)!; - if (token !== undefined) { - return token; + const keyword = textToKeyword.get(tokenValue); + if (keyword !== undefined) { + return token = keyword; } } } @@ -2016,7 +2022,7 @@ namespace ts { pos++; } tokenValue = text.substring(tokenPos, pos); - return token = SyntaxKind.Identifier; + return token = getIdentifierToken(); } else { return token = SyntaxKind.Unknown; diff --git a/src/compiler/sorting.ts b/src/compiler/sorting.ts deleted file mode 100755 index ef6535b83..000000000 --- a/src/compiler/sorting.ts +++ /dev/null @@ -1,753 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////// -// -// The MIT License (MIT) -// -// Copyright (c) 2015-present, Dom Chen. -// All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in the -// Software without restriction, including without limitation the rights to use, copy, -// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, -// and to permit persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -////////////////////////////////////////////////////////////////////////////////////// - -namespace ts { - - let checker: TypeChecker | null; - let sourceFiles: SourceFile[]; - let rootFileNames: string[]; - let dependencyMap: any; - let pathWeightMap: any; - let visitedBlocks: Block[]; - let calledMethods: MethodDeclaration[] = []; - - interface Map { - [index: string]: T; - [index: number]: T; - } - - function createMap(): Map { - const map: Map = Object.create(null); - // Using 'delete' on an object causes V8 to put the object in dictionary mode. - // This disables creation of hidden classes, which are expensive when an object is - // constantly changing shape. - map["__"] = undefined; - delete map["__"]; - return map; - } - - - export interface SortingResult { - sortedFileNames: string[], - circularReferences: string[] - } - - export function reorderSourceFiles(program: Program): SortingResult { - sourceFiles = program.getSourceFiles(); - rootFileNames = program.getRootFileNames(); - checker = program.getTypeChecker(); - visitedBlocks = []; - buildDependencyMap(); - let result = sortOnDependency(); - sourceFiles = []; - rootFileNames = []; - checker = null; - dependencyMap = null; - visitedBlocks = []; - return result; - } - - - function addDependency(file: string, dependent: string): void { - if (file == dependent) { - return; - } - let list = dependencyMap[file]; - if (!list) { - list = dependencyMap[file] = []; - } - if (list.indexOf(dependent) == -1) { - list.push(dependent); - } - } - - function buildDependencyMap(): void { - dependencyMap = createMap(); - for (let i = 0; i < sourceFiles.length; i++) { - let sourceFile = sourceFiles[i]; - if (sourceFile.isDeclarationFile) { - continue; - } - visitFile(sourceFile); - } - } - - function visitFile(sourceFile: SourceFile): void { - let statements = sourceFile.statements; - let length = statements.length; - for (let i = 0; i < length; i++) { - let statement = statements[i]; - if (hasModifier(statement, ModifierFlags.Ambient)) { // has the 'declare' keyword - continue; - } - visitStatement(statements[i]); - } - } - - function visitStatement(statement?: Statement): void { - if (!statement) { - return; - } - switch (statement.kind) { - case SyntaxKind.ExpressionStatement: - let expression = statement; - visitExpression(expression.expression); - break; - case SyntaxKind.ClassDeclaration: - checkInheriting(statement); - visitStaticMember(statement); - if (statement.transformFlags & TransformFlags.ContainsDecorators) { - visitClassDecorators(statement); - } - break; - case SyntaxKind.VariableStatement: - visitVariableList((statement).declarationList); - break; - case SyntaxKind.ImportEqualsDeclaration: - let importDeclaration = statement; - checkDependencyAtLocation(importDeclaration.moduleReference); - break; - case SyntaxKind.ModuleDeclaration: - visitModule(statement); - break; - case SyntaxKind.Block: - visitBlock(statement); - break; - case SyntaxKind.IfStatement: - const ifStatement = statement; - visitExpression(ifStatement.expression); - visitStatement(ifStatement.thenStatement); - visitStatement(ifStatement.elseStatement); - break; - case SyntaxKind.DoStatement: - case SyntaxKind.WhileStatement: - case SyntaxKind.WithStatement: - const doStatement = statement; - visitExpression(doStatement.expression); - visitStatement(doStatement.statement); - break; - case SyntaxKind.ForStatement: - const forStatement = statement; - visitExpression(forStatement.condition); - visitExpression(forStatement.incrementor); - if (forStatement.initializer) { - if (forStatement.initializer.kind === SyntaxKind.VariableDeclarationList) { - visitVariableList(forStatement.initializer); - } - else { - visitExpression(forStatement.initializer); - } - } - break; - case SyntaxKind.ForInStatement: - case SyntaxKind.ForOfStatement: - const forInStatement = statement; - visitExpression(forInStatement.expression); - if (forInStatement.initializer) { - if (forInStatement.initializer.kind === SyntaxKind.VariableDeclarationList) { - visitVariableList(forInStatement.initializer); - } - else { - visitExpression(forInStatement.initializer); - } - } - break; - case SyntaxKind.ReturnStatement: - visitExpression((statement).expression); - break; - case SyntaxKind.SwitchStatement: - const switchStatment = statement; - visitExpression(switchStatment.expression); - switchStatment.caseBlock.clauses.forEach(element => { - if (element.kind === SyntaxKind.CaseClause) { - visitExpression((element).expression); - } - (element).statements.forEach(element => { - visitStatement(element); - }) - }); - break; - case SyntaxKind.LabeledStatement: - visitStatement((statement).statement); - break; - case SyntaxKind.ThrowStatement: - visitExpression((statement).expression); - break; - case SyntaxKind.TryStatement: - const tryStatement = statement; - visitBlock(tryStatement.tryBlock); - visitBlock(tryStatement.finallyBlock); - if (tryStatement.catchClause) { - visitBlock(tryStatement.catchClause.block); - } - break; - } - } - - function visitModule(node: ModuleDeclaration): void { - if (node.body!.kind === SyntaxKind.ModuleDeclaration) { - visitModule(node.body); - return; - } - if (node.body!.kind === SyntaxKind.ModuleBlock) { - for (let statement of (node.body).statements) { - if (hasModifier(statement, ModifierFlags.Ambient)) { // has the 'declare' keyword - continue; - } - visitStatement(statement); - } - } - - } - - function checkDependencyAtLocation(node: Node): void { - let symbol = checker!.getSymbolAtLocation(node); - if (!symbol || !symbol.declarations) { - return; - } - let sourceFile = getSourceFileOfNode(symbol.declarations[0]); - if (!sourceFile || sourceFile.isDeclarationFile) { - return; - } - addDependency(getSourceFileOfNode(node).fileName, sourceFile.fileName); - } - - function checkInheriting(node: ClassDeclaration): void { - if (!node.heritageClauses) { - return; - } - let heritageClause: HeritageClause | null = null; - for (const clause of node.heritageClauses) { - if (clause.token === SyntaxKind.ExtendsKeyword) { - heritageClause = clause; - break; - } - } - if (!heritageClause) { - return; - } - let superClasses = heritageClause.types; - if (!superClasses) { - return; - } - superClasses.forEach(superClass => { - checkDependencyAtLocation(superClass.expression); - }); - } - - function visitStaticMember(node: ClassDeclaration): void { - let members = node.members; - if (!members) { - return; - } - for (let member of members) { - if (!hasModifier(member, ModifierFlags.Static)) { - continue; - } - if (member.kind == SyntaxKind.PropertyDeclaration) { - let property = member; - visitExpression(property.initializer); - } - } - } - - function visitClassDecorators(node: ClassDeclaration): void { - if (node.decorators) { - visitDecorators(node.decorators); - } - let members = node.members; - if (!members) { - return; - } - for (let member of members) { - let decorators: NodeArray | undefined; - let functionLikeMember: FunctionLikeDeclaration | undefined; - if (member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor) { - const accessors = getAllAccessorDeclarations(node.members, member); - if (member !== accessors.firstAccessor) { - continue; - } - decorators = accessors.firstAccessor.decorators; - if (!decorators && accessors.secondAccessor) { - decorators = accessors.secondAccessor.decorators; - } - functionLikeMember = accessors.setAccessor; - } - else { - decorators = member.decorators; - if (member.kind === SyntaxKind.MethodDeclaration) { - functionLikeMember = member; - } - } - if (decorators) { - visitDecorators(decorators); - } - - if (functionLikeMember) { - for (const parameter of functionLikeMember.parameters) { - if (parameter.decorators) { - visitDecorators(parameter.decorators); - } - } - } - } - } - - function visitDecorators(decorators: NodeArray): void { - for (let decorator of decorators) { - visitCallExpression(decorator.expression); - } - } - - function visitExpression(expression?: Expression): void { - if (!expression) { - return; - } - switch (expression.kind) { - case SyntaxKind.NewExpression: - case SyntaxKind.CallExpression: - visitCallArguments(expression); - visitCallExpression((expression).expression); - break; - case SyntaxKind.Identifier: - checkDependencyAtLocation(expression); - break; - case SyntaxKind.PropertyAccessExpression: - checkDependencyAtLocation(expression); - break; - case SyntaxKind.ElementAccessExpression: - visitExpression((expression).expression); - break; - case SyntaxKind.ObjectLiteralExpression: - visitObjectLiteralExpression(expression); - break; - case SyntaxKind.ArrayLiteralExpression: - let arrayLiteral = expression; - arrayLiteral.elements.forEach(visitExpression); - break; - case SyntaxKind.TemplateExpression: - let template = expression; - template.templateSpans.forEach(span => { - visitExpression(span.expression); - }); - break; - case SyntaxKind.ParenthesizedExpression: - let parenthesized = expression; - visitExpression(parenthesized.expression); - break; - case SyntaxKind.BinaryExpression: - visitBinaryExpression(expression); - break; - case SyntaxKind.PostfixUnaryExpression: - case SyntaxKind.PrefixUnaryExpression: - visitExpression((expression).operand); - break; - case SyntaxKind.DeleteExpression: - visitExpression((expression).expression); - break; - case ts.SyntaxKind.TaggedTemplateExpression: - visitExpression((expression).tag); - visitExpression((expression).template); - break; - case ts.SyntaxKind.ConditionalExpression: - visitExpression((expression).condition); - visitExpression((expression).whenTrue); - visitExpression((expression).whenFalse); - break; - - case ts.SyntaxKind.SpreadElement: - visitExpression((expression).expression); - break; - case ts.SyntaxKind.VoidExpression: - visitExpression((expression).expression); - break; - case ts.SyntaxKind.YieldExpression: - visitExpression((expression).expression); - break; - case ts.SyntaxKind.AwaitExpression: - visitExpression((expression).expression); - break; - case ts.SyntaxKind.TypeOfExpression: - visitExpression((expression).expression); - break; - case ts.SyntaxKind.NonNullExpression: - visitExpression((expression).expression); - break; - case ts.SyntaxKind.TypeAssertionExpression: - visitExpression((expression).expression); - break; - } - - // FunctionExpression - // ArrowFunction - // ClassExpression - // OmittedExpression - // ExpressionWithTypeArguments - // AsExpression - } - - function visitBinaryExpression(binary: BinaryExpression): void { - let left = binary.left; - let right = binary.right; - visitExpression(left); - visitExpression(right); - if (binary.operatorToken.kind === SyntaxKind.EqualsToken && - (left.kind === SyntaxKind.Identifier || left.kind === SyntaxKind.PropertyAccessExpression) && - (right.kind === SyntaxKind.Identifier || right.kind === SyntaxKind.PropertyAccessExpression)) { - let symbol = checker!.getSymbolAtLocation(left); - if (!symbol || !symbol.declarations) { - return; - } - for (let declaration of symbol.declarations) { - if (declaration.kind === SyntaxKind.VariableDeclaration || declaration.kind === SyntaxKind.PropertyDeclaration) { - let variable = declaration; - if (variable.initializer) { - continue; - } - if (!variable.delayInitializerList) { - variable.delayInitializerList = []; - } - variable.delayInitializerList.push(right); - if (variable.callerList) { - for (let callerFileName of variable.callerList) { - checkCallTarget(callerFileName, right); - } - } - } - } - } - } - - function visitObjectLiteralExpression(objectLiteral: ObjectLiteralExpression): void { - objectLiteral.properties.forEach(element => { - switch (element.kind) { - case SyntaxKind.PropertyAssignment: - visitExpression((element).initializer); - break; - case SyntaxKind.ShorthandPropertyAssignment: - visitExpression((element).objectAssignmentInitializer); - break; - case SyntaxKind.SpreadAssignment: - visitExpression((element).expression); - break; - } - }); - } - - function visitCallArguments(callExpression: CallExpression): void { - if (callExpression.arguments) { - callExpression.arguments.forEach(argument => { - visitExpression(argument); - }); - } - } - - function visitCallExpression(expression: Expression): void { - expression = escapeParenthesized(expression); - visitExpression(expression); - switch (expression.kind) { - case SyntaxKind.FunctionExpression: - let functionExpression = expression; - visitBlock(functionExpression.body); - break; - case SyntaxKind.PropertyAccessExpression: - case SyntaxKind.Identifier: - let callerFileName = getSourceFileOfNode(expression).fileName; - checkCallTarget(callerFileName, expression); - break; - case SyntaxKind.CallExpression: - visitReturnedFunction((expression).expression); - break; - } - } - - function visitReturnedFunction(expression: Expression): Expression[] { - expression = escapeParenthesized(expression); - let returnExpressions: Expression[] = []; - if (expression.kind === SyntaxKind.CallExpression) { - let expressions = visitReturnedFunction((expression).expression); - for (let returnExpression of expressions) { - let returns = visitReturnedFunction(returnExpression); - returnExpressions = returnExpressions.concat(returns); - } - return returnExpressions; - } - - let functionBlocks: Block[] = []; - switch (expression.kind) { - case SyntaxKind.FunctionExpression: - functionBlocks.push((expression).body); - break; - case SyntaxKind.PropertyAccessExpression: - case SyntaxKind.Identifier: - let callerFileName = getSourceFileOfNode(expression).fileName; - let declarations: Declaration[] = []; - getForwardDeclarations(expression, declarations, callerFileName); - for (let declaration of declarations) { - let sourceFile = getSourceFileOfNode(declaration); - if (!sourceFile || sourceFile.isDeclarationFile) { - continue; - } - if (declaration.kind === SyntaxKind.FunctionDeclaration || - declaration.kind === SyntaxKind.MethodDeclaration) { - functionBlocks.push((declaration).body!); - } - } - break; - } - - for (let block of functionBlocks) { - for (let statement of block.statements) { - if (statement.kind === SyntaxKind.ReturnStatement) { - let returnExpression = (statement).expression; - returnExpressions.push(returnExpression!); - visitCallExpression(returnExpression!); - } - } - } - return returnExpressions; - } - - function escapeParenthesized(expression: Expression): Expression { - if (expression.kind === SyntaxKind.ParenthesizedExpression) { - return escapeParenthesized((expression).expression); - } - return expression; - } - - function checkCallTarget(callerFileName: string, target: Node): void { - let declarations: Declaration[] = []; - getForwardDeclarations(target, declarations, callerFileName); - for (let declaration of declarations) { - let sourceFile = getSourceFileOfNode(declaration); - if (!sourceFile || sourceFile.isDeclarationFile) { - continue; - } - addDependency(callerFileName, sourceFile.fileName); - if (declaration.kind === SyntaxKind.FunctionDeclaration) { - visitBlock((declaration).body); - } else if (declaration.kind === SyntaxKind.MethodDeclaration) { - visitBlock((declaration).body); - calledMethods.push(declaration); - } - else if (declaration.kind === SyntaxKind.ClassDeclaration) { - checkClassInstantiation(declaration); - } - } - } - - function getForwardDeclarations(reference: Node, declarations: Declaration[], callerFileName: string): void { - let symbol = checker!.getSymbolAtLocation(reference); - if (!symbol || !symbol.declarations) { - return; - } - for (let declaration of symbol.declarations) { - switch (declaration.kind) { - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.ClassDeclaration: - if (declarations.indexOf(declaration) == -1) { - declarations.push(declaration); - } - break; - case SyntaxKind.ImportEqualsDeclaration: - getForwardDeclarations((declaration).moduleReference, declarations, callerFileName); - break; - case SyntaxKind.VariableDeclaration: - case SyntaxKind.PropertyDeclaration: - const variable = declaration; - const initializer = variable.initializer; - if (initializer) { - if (initializer.kind === SyntaxKind.Identifier || initializer.kind === SyntaxKind.PropertyAccessExpression) { - getForwardDeclarations(initializer, declarations, callerFileName); - } - } - else { - if (variable.delayInitializerList) { - for (let expression of variable.delayInitializerList) { - getForwardDeclarations(expression, declarations, callerFileName); - } - } - if (variable.callerList) { - if (variable.callerList.indexOf(callerFileName) == -1) { - variable.callerList.push(callerFileName); - } - } - else { - variable.callerList = [callerFileName]; - } - } - break; - } - } - } - - function checkClassInstantiation(node: ClassDeclaration): string[] { - let methodNames: string[] = []; - let superClass = getClassExtendsHeritageElement(node); - if (superClass) { - let type = checker!.getTypeAtLocation(superClass); - if (type && type.symbol) { - let declaration = ts.getDeclarationOfKind(type.symbol, SyntaxKind.ClassDeclaration); - if (declaration) { - methodNames = checkClassInstantiation(declaration); - } - } - } - - let members = node.members; - if (!members) { - return []; - } - let index = calledMethods.length; - for (let member of members) { - if (hasModifier(member, ModifierFlags.Static)) { - continue; - } - if (member.kind === SyntaxKind.MethodDeclaration) { // called by super class. - let methodName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name!)); - if (methodNames.indexOf(methodName) != -1) { - visitBlock((member).body); - } - } - if (member.kind === SyntaxKind.PropertyDeclaration) { - let property = member; - visitExpression(property.initializer); - } - else if (member.kind === SyntaxKind.Constructor) { - let constructor = member; - visitBlock(constructor.body); - } - } - - for (let i = index; i < calledMethods.length; i++) { - let method = calledMethods[i]; - for (let memeber of members) { - if (memeber === method) { - let methodName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(method.name)); - methodNames.push(methodName); - } - } - } - if (index == 0) { - calledMethods.length = 0; - } - return methodNames; - } - - function visitBlock(block?: Block): void { - if (!block || visitedBlocks.indexOf(block) != -1) { - return; - } - visitedBlocks.push(block); - for (let statement of block.statements) { - visitStatement(statement); - } - visitedBlocks.pop(); - } - - function visitVariableList(variables?: VariableDeclarationList) { - if (!variables) { - return; - } - variables.declarations.forEach(declaration => { - visitExpression(declaration.initializer); - }); - } - - function sortOnDependency(): SortingResult { - let result: SortingResult = {}; - result.sortedFileNames = []; - result.circularReferences = []; - pathWeightMap = createMap(); - let dtsFiles: SourceFile[] = []; - let tsFiles: SourceFile[] = []; - for (let sourceFile of sourceFiles) { - let path = sourceFile.fileName; - if (sourceFile.isDeclarationFile) { - pathWeightMap[path] = 10000; - dtsFiles.push(sourceFile); - continue; - } - let references = updatePathWeight(path, 0, [path]); - if (references.length > 0) { - result.circularReferences = references; - break; - } - tsFiles.push(sourceFile); - } - if (result.circularReferences.length === 0) { - tsFiles.sort(function (a: SourceFile, b: SourceFile): number { - return pathWeightMap[b.fileName] - pathWeightMap[a.fileName]; - }); - sourceFiles.length = 0; - rootFileNames.length = 0; - dtsFiles.concat(tsFiles).forEach(sourceFile => { - sourceFiles.push(sourceFile); - rootFileNames.push(sourceFile.fileName); - result.sortedFileNames.push(sourceFile.fileName); - }); - } - pathWeightMap = null; - return result; - } - - function updatePathWeight(path: string, weight: number, references: string[]): string[] { - if (pathWeightMap[path] === undefined) { - pathWeightMap[path] = weight; - } - else { - if (pathWeightMap[path] < weight) { - pathWeightMap[path] = weight; - } - else { - return []; - } - } - let list = dependencyMap[path]; - if (!list) { - return []; - } - for (let parentPath of list) { - if (references.indexOf(parentPath) != -1) { - references.push(parentPath); - return references; - } - let result = updatePathWeight(parentPath, weight + 1, references.concat(parentPath)); - if (result.length > 0) { - return result; - } - } - return []; - } - - function getSourceFileOfNode(node: Node): SourceFile { - while (node && node.kind !== SyntaxKind.SourceFile) { - node = node.parent; - } - return node; - } -} diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index a13166fd5..b78202e0c 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -32,10 +32,6 @@ namespace ts { addRange(transformers, customTransformers && customTransformers.before); - if(compilerOptions.defines || compilerOptions.emitReflection){ - transformers.push(transformTypeScriptPlus); - } - transformers.push(transformTypeScript); if (jsx === JsxEmit.React) { diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 9b42f2f25..dcb0d9ac2 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -56,9 +56,9 @@ namespace ts { } const enum Jump { - Break = 1 << 1, - Continue = 1 << 2, - Return = 1 << 3 + Break = 1 << 1, + Continue = 1 << 2, + Return = 1 << 3 } interface ConvertedLoopState { @@ -267,7 +267,6 @@ namespace ts { const compilerOptions = context.getCompilerOptions(); const resolver = context.getEmitResolver(); - const typeChecker = context.getEmitHost().getTypeChecker(); const previousOnSubstituteNode = context.onSubstituteNode; const previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; @@ -1040,11 +1039,11 @@ namespace ts { * @returns The new statement offset into the `statements` array. */ function declareOrCaptureOrReturnThisForConstructorIfNeeded( - statements: Statement[], - ctor: ConstructorDeclaration | undefined, - isDerivedClass: boolean, - hasSynthesizedSuper: boolean, - statementOffset: number) { + statements: Statement[], + ctor: ConstructorDeclaration | undefined, + isDerivedClass: boolean, + hasSynthesizedSuper: boolean, + statementOffset: number) { // If this isn't a derived class, just capture 'this' for arrow functions if necessary. if (!isDerivedClass) { if (ctor) { @@ -1546,13 +1545,7 @@ namespace ts { break; case SyntaxKind.MethodDeclaration: - const method = member; - if (method.isJumpTarget || (method.original && (method.original).isJumpTarget)) { - transformJumpTarget(statements, getClassMemberPrefix(node, member), member); - } - else { - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); - } + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; case SyntaxKind.GetAccessor: @@ -1575,44 +1568,6 @@ namespace ts { } } - function transformJumpTarget(statements: Statement[], receiver: LeftHandSideExpression, member: MethodDeclaration): void { - const memberName = createMemberAccessForPropertyName(receiver, visitNode(member.name, visitor, isPropertyName), /*location*/ member.name); - statements.push(createStatement( - createAssignment(memberName, member.name), - )); - - const sourceMapRange = getSourceMapRange(member); - const memberFunction = transformMethodToFunctionDeclaration(member, /*location*/ member, /*name*/ member.name); - setEmitFlags(memberFunction, EmitFlags.NoComments); - setSourceMapRange(memberFunction, sourceMapRange); - statements.push(memberFunction); - } - - function transformMethodToFunctionDeclaration(node: FunctionLikeDeclaration, location: TextRange, name: Identifier): FunctionDeclaration { - const savedConvertedLoopState = convertedLoopState; - convertedLoopState = undefined; - const ancestorFacts = enterSubtree(HierarchyFacts.FunctionExcludes, HierarchyFacts.FunctionIncludes); - const parameters = visitParameterList(node.parameters, visitor, context); - const body = transformFunctionBody(node); - exitSubtree(ancestorFacts, HierarchyFacts.PropagateNewTargetMask, HierarchyFacts.None); - convertedLoopState = savedConvertedLoopState; - return setOriginalNode( - setTextRange( - createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - node.asteriskToken, - name, - /*typeParameters*/ undefined, - parameters, - /*type*/ undefined, - body), - location - ), - /*original*/ node - ); - } - /** * Transforms a SemicolonClassElement into a statement for a class body function. * @@ -1693,15 +1648,19 @@ namespace ts { const properties: ObjectLiteralElementLike[] = []; if (getAccessor) { - const getterExpression = createAccessorExpression(getAccessor, firstAccessor, receiver, container); - const getter = createPropertyAssignment("get", getterExpression); + const getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); + setSourceMapRange(getterFunction, getSourceMapRange(getAccessor)); + setEmitFlags(getterFunction, EmitFlags.NoLeadingComments); + const getter = createPropertyAssignment("get", getterFunction); setCommentRange(getter, getCommentRange(getAccessor)); properties.push(getter); } if (setAccessor) { - const setterExpression = createAccessorExpression(setAccessor, firstAccessor, receiver, container); - const setter = createPropertyAssignment("set", setterExpression); + const setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); + setSourceMapRange(setterFunction, getSourceMapRange(setAccessor)); + setEmitFlags(setterFunction, EmitFlags.NoLeadingComments); + const setter = createPropertyAssignment("set", setterFunction); setCommentRange(setter, getCommentRange(setAccessor)); properties.push(setter); } @@ -1728,79 +1687,6 @@ namespace ts { return call; } - /** - * If the accessor method contains only one call to another method, use that method to define the accessor directly. - */ - function createAccessorExpression(accessor: AccessorDeclaration, firstAccessor: AccessorDeclaration, receiver: LeftHandSideExpression, container: Node): Expression { - let expression: Expression; - let method = compilerOptions.accessorOptimization ? getJumpTargetOfAccessor(accessor) : null; - if (method) { - const methodName = getMutableClone(method.name); - setEmitFlags(methodName, EmitFlags.NoComments | EmitFlags.NoTrailingSourceMap); - setSourceMapRange(methodName, method.name); - if (firstAccessor.pos > method.pos) { // the target method has been already emitted. - const target = getMutableClone(receiver); - setEmitFlags(target, EmitFlags.NoComments | EmitFlags.NoTrailingSourceMap); - setSourceMapRange(target, firstAccessor.name); - expression = createPropertyAccess(target, methodName); - } - else { - expression = methodName; - method.isJumpTarget = true; - } - } - else { - expression = transformFunctionLikeToExpression(accessor, /*location*/ undefined, /*name*/ undefined, container); - } - setSourceMapRange(expression, getSourceMapRange(accessor)); - setEmitFlags(expression, EmitFlags.NoLeadingComments); - return expression; - } - - function getJumpTargetOfAccessor(accessor: AccessorDeclaration): MethodDeclaration | undefined { - if (accessor.body!.statements.length != 1) { - return undefined; - } - let statement = accessor.body!.statements[0]; - if (statement.kind !== SyntaxKind.ExpressionStatement && - statement.kind !== SyntaxKind.ReturnStatement) { - return undefined; - } - let expression = (statement).expression; - if (expression!.kind !== SyntaxKind.CallExpression) { - return undefined; - } - let callExpression = expression; - if (accessor.kind === SyntaxKind.SetAccessor) { - if (callExpression.arguments.length != 1) { - return undefined; - } - let argument = callExpression.arguments[0]; - if (argument.kind !== SyntaxKind.Identifier) { - return undefined; - } - } - else { - if (callExpression.arguments.length != 0) { - return undefined; - } - } - - if (callExpression.expression.kind !== SyntaxKind.PropertyAccessExpression) { - return undefined; - } - let propertyExpression = callExpression.expression; - if (propertyExpression.expression.kind !== SyntaxKind.ThisKeyword) { - return undefined; - } - let symbol = typeChecker.getSymbolAtLocation(propertyExpression.name); - if (!symbol) { - return undefined; - } - return getDeclarationOfKind(symbol, SyntaxKind.MethodDeclaration); - } - - /** * Visits an ArrowFunction and transforms it into a FunctionExpression. * @@ -3925,8 +3811,8 @@ namespace ts { function visitSuperKeyword(isExpressionOfCall: boolean): LeftHandSideExpression { return hierarchyFacts & HierarchyFacts.NonStaticClassElement && !isExpressionOfCall - ? createPropertyAccess(createFileLevelUniqueName("_super"), "prototype") - : createFileLevelUniqueName("_super"); + ? createPropertyAccess(createFileLevelUniqueName("_super"), "prototype") + : createFileLevelUniqueName("_super"); } function visitMetaProperty(node: MetaProperty) { diff --git a/src/compiler/transformers/tsPlus.ts b/src/compiler/transformers/tsPlus.ts deleted file mode 100755 index 34175d70d..000000000 --- a/src/compiler/transformers/tsPlus.ts +++ /dev/null @@ -1,266 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////// -// -// The MIT License (MIT) -// -// Copyright (c) 2015-present, Dom Chen. -// All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in the -// Software without restriction, including without limitation the rights to use, copy, -// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, -// and to permit persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -////////////////////////////////////////////////////////////////////////////////////// - -/*@internal*/ -namespace ts { - - export function transformTypeScriptPlus(context: TransformationContext) { - const compilerOptions = context.getCompilerOptions(); - const compilerDefines = getCompilerDefines(compilerOptions.defines!); - const typeChecker = compilerOptions.emitReflection || compilerDefines ? context.getEmitHost().getTypeChecker() : null; - const previousOnSubstituteNode = context.onSubstituteNode; - if (compilerDefines) { - context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(SyntaxKind.Identifier); - } - - return chainBundle(transformSourceFile); - - function transformSourceFile(node: SourceFile) { - if (!compilerOptions.emitReflection) { - return node; - } - let visited = updateSourceFileNode(node, visitNodes(node.statements, visitStatement, isStatement)); - addEmitHelpers(visited, context.readEmitHelpers()); - return visited; - } - - function visitStatement(node: Node): VisitResult { - if (hasModifier(node, ModifierFlags.Ambient)) { - return node; - } - if (node.kind === SyntaxKind.ClassDeclaration) { - return visitClassDeclaration(node); - } - if (node.kind === SyntaxKind.ModuleDeclaration) { - return visitModule(node); - } - return node; - } - - function visitModule(node: NamespaceDeclaration): NamespaceDeclaration { - if (node.body.kind === SyntaxKind.ModuleDeclaration) { - return updateModuleDeclaration(node, visitModule(node.body)); - } - if (node.body.kind === SyntaxKind.ModuleBlock) { - const body = updateModuleBlock(node.body, visitNodes( - (node.body).statements, visitStatement, isStatement)); - return updateModuleDeclaration(node, body); - } - return node; - } - - function updateModuleDeclaration(node: NamespaceDeclaration, body: ModuleBody) { - if (node.body !== body) { - let updated = getMutableClone(node); - updated.body = body; - return updateNode(updated, node); - } - return node - } - - function updateModuleBlock(node: ModuleBlock, statements: NodeArray) { - if (node.statements !== statements) { - let updated = getMutableClone(node); - updated.statements = createNodeArray(statements); - return updateNode(updated, node); - } - return node; - } - - function visitClassDeclaration(node: ClassDeclaration): VisitResult { - const classStatement = getMutableClone(node); - const statements: Statement[] = [classStatement]; - - let interfaceMap: any = {}; - getImplementedInterfaces(node, interfaceMap); - let allInterfaces: string[] = Object.keys(interfaceMap); - let interfaces: string[]; - let superTypes = getSuperClassTypes(node); - if (superTypes) { - interfaces = []; - for (let type of allInterfaces) { - if (superTypes.indexOf(type) === -1) { - interfaces.push(type); - } - } - } - else { - interfaces = allInterfaces; - } - node.typeNames = interfaces; - let fullClassName = typeChecker!.getFullyQualifiedName(node.symbol); - const expression = createReflectHelper(context, node.name!, fullClassName, interfaces); - setSourceMapRange(expression, createRange(node.name!.pos, node.end)); - - const statement = createStatement(expression); - setSourceMapRange(statement, createRange(-1, node.end)); - statements.push(statement); - - return statements; - } - - function getImplementedInterfaces(node: Node, result: any) { - let superInterfaces: NodeArray | undefined = undefined; - if (node.kind === SyntaxKind.ClassDeclaration) { - superInterfaces = getClassImplementsHeritageClauseElements(node); - } - else { - superInterfaces = getInterfaceBaseTypeNodes(node); - } - if (superInterfaces) { - superInterfaces.forEach(superInterface => { - let type = typeChecker!.getTypeAtLocation(superInterface) - if (type && type.symbol && type.symbol.flags & SymbolFlags.Interface) { - let symbol = type.symbol; - let fullName = typeChecker!.getFullyQualifiedName(symbol); - result[fullName] = true; - const declaration = ts.getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration); - if (declaration) { - getImplementedInterfaces(declaration, result); - } - } - }); - } - } - - function getSuperClassTypes(node: ClassLikeDeclaration): string[] | undefined { - let superClass = getClassExtendsHeritageElement(node); - if (!superClass) { - return undefined; - } - let type = typeChecker!.getTypeAtLocation(superClass); - if (!type || !type.symbol) { - return undefined; - } - let declaration = ts.getDeclarationOfKind(type.symbol, SyntaxKind.ClassDeclaration); - return declaration ? declaration.typeNames : undefined; - } - - - function getCompilerDefines(defines: MapLike): MapLike | null { - if (!defines) { - return null; - } - let compilerDefines: MapLike = {}; - let keys = Object.keys(defines); - for (let key of keys) { - let value = defines[key]; - let type = typeof value; - switch (type) { - case "boolean": - case "number": - compilerDefines[key] = value.toString(); - break; - case "string": - compilerDefines[key] = "\"" + value + "\""; - break; - } - } - if (Object.keys(compilerDefines).length == 0) { - return null; - } - return compilerDefines; - } - - function isDefinedConstant(node: Identifier): boolean { - let nodeText = ts.getTextOfIdentifierOrLiteral(node); - if (compilerDefines![nodeText] === undefined) { - return false; - } - if (!node.parent) { - return false - } - if (node.parent.kind === SyntaxKind.VariableDeclaration && (node.parent).name === node) { - return false; - } - if (node.parent.kind === SyntaxKind.BinaryExpression) { - let parent = node.parent; - if (parent.left === node && parent.operatorToken.kind === SyntaxKind.EqualsToken) { - return false; - } - } - - let symbol = typeChecker!.getSymbolAtLocation(node); - if (!symbol || !symbol.declarations) { - return false; - } - let declaration = symbol.declarations[0]; - if (!declaration) { - return false; - } - if (declaration.kind !== SyntaxKind.VariableDeclaration) { - return false; - } - let statement = declaration.parent.parent; - return (statement.parent.kind === SyntaxKind.SourceFile); - } - - /** - * Hooks node substitutions. - * @param emitContext The context for the emitter. - * @param node The node to substitute. - */ - function onSubstituteNode(hint: EmitHint, node: Node) { - node = previousOnSubstituteNode(hint, node); - if (isIdentifier(node) && isDefinedConstant(node)) { - let nodeText = ts.getTextOfIdentifierOrLiteral(node); - return createIdentifier(compilerDefines![nodeText]); - } - return node; - } - } - - const reflectHelper: EmitHelper = { - name: "typescript:reflect", - scoped: false, - priority: 0, - text: ` - var __reflect = (this && this.__reflect) || function (p, c, t) { - p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; - };` - }; - - function createReflectHelper(context: TransformationContext, name: Identifier, fullClassName: string, interfaces: string[]) { - context.requestEmitHelper(reflectHelper); - let argumentsArray: Expression[] = [ - createPropertyAccess(name, createIdentifier("prototype")), - createLiteral(fullClassName) - ]; - if (interfaces.length) { - let elements: Expression[] = []; - for (let value of interfaces) { - elements.push(createLiteral(value)); - } - argumentsArray.push(createArrayLiteral(elements)); - } - return createCall( - getHelperName("__reflect"), - /*typeArguments*/ undefined, - argumentsArray - ); - } -} diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index 002674881..4822f1dc0 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -42,8 +42,6 @@ "transformers/declarations/diagnostics.ts", "transformers/declarations.ts", "transformer.ts", - "transformers/tsPlus.ts", - "sorting.ts", "sourcemap.ts", "comments.ts", "emitter.ts", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5a514ab7f..9a41aebb5 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -24,7 +24,84 @@ namespace ts { | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.NoSubstitutionTemplateLiteral - | SyntaxKind.Unknown; + | SyntaxKind.Unknown + | KeywordSyntaxKind; + + export type KeywordSyntaxKind = + | SyntaxKind.AbstractKeyword + | SyntaxKind.AnyKeyword + | SyntaxKind.AsKeyword + | SyntaxKind.BooleanKeyword + | SyntaxKind.BreakKeyword + | SyntaxKind.CaseKeyword + | SyntaxKind.CatchKeyword + | SyntaxKind.ClassKeyword + | SyntaxKind.ContinueKeyword + | SyntaxKind.ConstKeyword + | SyntaxKind.ConstructorKeyword + | SyntaxKind.DebuggerKeyword + | SyntaxKind.DeclareKeyword + | SyntaxKind.DefaultKeyword + | SyntaxKind.DeleteKeyword + | SyntaxKind.DoKeyword + | SyntaxKind.ElseKeyword + | SyntaxKind.EnumKeyword + | SyntaxKind.ExportKeyword + | SyntaxKind.ExtendsKeyword + | SyntaxKind.FalseKeyword + | SyntaxKind.FinallyKeyword + | SyntaxKind.ForKeyword + | SyntaxKind.FromKeyword + | SyntaxKind.FunctionKeyword + | SyntaxKind.GetKeyword + | SyntaxKind.IfKeyword + | SyntaxKind.ImplementsKeyword + | SyntaxKind.ImportKeyword + | SyntaxKind.InKeyword + | SyntaxKind.InferKeyword + | SyntaxKind.InstanceOfKeyword + | SyntaxKind.InterfaceKeyword + | SyntaxKind.IsKeyword + | SyntaxKind.KeyOfKeyword + | SyntaxKind.LetKeyword + | SyntaxKind.ModuleKeyword + | SyntaxKind.NamespaceKeyword + | SyntaxKind.NeverKeyword + | SyntaxKind.NewKeyword + | SyntaxKind.NullKeyword + | SyntaxKind.NumberKeyword + | SyntaxKind.ObjectKeyword + | SyntaxKind.PackageKeyword + | SyntaxKind.PrivateKeyword + | SyntaxKind.ProtectedKeyword + | SyntaxKind.PublicKeyword + | SyntaxKind.ReadonlyKeyword + | SyntaxKind.RequireKeyword + | SyntaxKind.GlobalKeyword + | SyntaxKind.ReturnKeyword + | SyntaxKind.SetKeyword + | SyntaxKind.StaticKeyword + | SyntaxKind.StringKeyword + | SyntaxKind.SuperKeyword + | SyntaxKind.SwitchKeyword + | SyntaxKind.SymbolKeyword + | SyntaxKind.ThisKeyword + | SyntaxKind.ThrowKeyword + | SyntaxKind.TrueKeyword + | SyntaxKind.TryKeyword + | SyntaxKind.TypeKeyword + | SyntaxKind.TypeOfKeyword + | SyntaxKind.UndefinedKeyword + | SyntaxKind.UniqueKeyword + | SyntaxKind.UnknownKeyword + | SyntaxKind.VarKeyword + | SyntaxKind.VoidKeyword + | SyntaxKind.WhileKeyword + | SyntaxKind.WithKeyword + | SyntaxKind.YieldKeyword + | SyntaxKind.AsyncKeyword + | SyntaxKind.AwaitKeyword + | SyntaxKind.OfKeyword; export type JsxTokenSyntaxKind = | SyntaxKind.LessThanSlashToken @@ -809,10 +886,6 @@ namespace ts { exclamationToken?: ExclamationToken; // Optional definite assignment assertion type?: TypeNode; // Optional type annotation initializer?: Expression; // Optional initializer - /* @internal */ - callerList?: string[]; - /* @internal */ - delayInitializerList?: Expression[]; } export interface VariableDeclarationList extends Node { @@ -988,7 +1061,6 @@ namespace ts { parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; - isJumpTarget?: boolean; } export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { @@ -2057,7 +2129,6 @@ namespace ts { typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; - typeNames?: string[]; } export interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { @@ -4450,13 +4521,6 @@ namespace ts { /*@internal*/ watch?: boolean; esModuleInterop?: boolean; - /* extra options */ - accessorOptimization?: boolean; - defines?: MapLike; - emitReflection?: boolean; - noEmitJs?: boolean; - reorderFiles?: boolean; - [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } @@ -5111,8 +5175,6 @@ namespace ts { /* @internal */ isSourceFileFromExternalLibrary(file: SourceFile): boolean; - /* @internal */ - getTypeChecker(): TypeChecker; getLibFileFromReference(ref: FileReference): SourceFile | undefined; getCommonSourceDirectory(): string; diff --git a/src/harness/client.ts b/src/harness/client.ts index fd80f1491..e2766d605 100644 --- a/src/harness/client.ts +++ b/src/harness/client.ts @@ -694,6 +694,10 @@ namespace ts.server { return response.body!.map(entry => this.decodeSpan(entry, fileName)); // TODO: GH#18217 } + configurePlugin(pluginName: string, configuration: any): void { + this.processRequest("configurePlugin", { pluginName, configuration }); + } + getIndentationAtPosition(_fileName: string, _position: number, _options: EditorOptions): number { return notImplemented(); } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 081e59860..ed9f66981 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -3399,6 +3399,10 @@ Actual: ${stringify(fullActual)}`); } } } + + public configurePlugin(pluginName: string, configuration: any): void { + (this.languageService).configurePlugin(pluginName, configuration); + } } function updateTextRangeForTextChanges({ pos, end }: ts.TextRange, textChanges: ReadonlyArray): ts.TextRange { @@ -3462,19 +3466,20 @@ Actual: ${stringify(fullActual)}`); function runCode(code: string, state: TestState): void { // Compile and execute the test const wrappedCode = - `(function(test, goTo, verify, edit, debug, format, cancellation, classification, verifyOperationIsCancelled) { + `(function(test, goTo, plugins, verify, edit, debug, format, cancellation, classification, verifyOperationIsCancelled) { ${code} })`; try { const test = new FourSlashInterface.Test(state); const goTo = new FourSlashInterface.GoTo(state); + const plugins = new FourSlashInterface.Plugins(state); const verify = new FourSlashInterface.Verify(state); const edit = new FourSlashInterface.Edit(state); const debug = new FourSlashInterface.Debug(state); const format = new FourSlashInterface.Format(state); const cancellation = new FourSlashInterface.Cancellation(state); const f = eval(wrappedCode); - f(test, goTo, verify, edit, debug, format, cancellation, FourSlashInterface.Classification, verifyOperationIsCancelled); + f(test, goTo, plugins, verify, edit, debug, format, cancellation, FourSlashInterface.Classification, verifyOperationIsCancelled); } catch (err) { throw err; @@ -3867,7 +3872,7 @@ ${code} } // put ranges in the correct order - localRanges = localRanges.sort((a, b) => a.pos < b.pos ? -1 : 1); + localRanges = localRanges.sort((a, b) => a.pos < b.pos ? -1 : a.pos === b.pos && a.end > b.end ? -1 : 1); localRanges.forEach((r) => { ranges.push(r); }); return { @@ -3974,6 +3979,15 @@ namespace FourSlashInterface { } } + export class Plugins { + constructor (private state: FourSlash.TestState) { + } + + public configurePlugin(pluginName: string, configuration: any): void { + this.state.configurePlugin(pluginName, configuration); + } + } + export class GoTo { constructor(private state: FourSlash.TestState) { } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 23ee10d74..4358ce64d 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1159,7 +1159,7 @@ namespace Harness { } // If not a primitive, the possible types are specified in what is effectively a map of options. case "list": - return ts.parseListTypeOption(option, value, errors); + return ts.parseListTypeOption(option, value, errors); // tslint:disable-line no-unnecessary-type-assertion default: return ts.parseCustomTypeOption(option, value, errors); } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index e90f29446..ee35ab360 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -833,6 +833,36 @@ namespace Harness.LanguageService { error: undefined }; + // Accepts configurations + case "configurable-diagnostic-adder": + let customMessage = "default message"; + return { + module: () => ({ + create(info: ts.server.PluginCreateInfo) { + customMessage = info.config.message; + const proxy = makeDefaultProxy(info); + proxy.getSemanticDiagnostics = filename => { + const prev = info.languageService.getSemanticDiagnostics(filename); + const sourceFile: ts.SourceFile = info.project.getSourceFile(ts.toPath(filename, /*basePath*/ undefined, ts.createGetCanonicalFileName(info.serverHost.useCaseSensitiveFileNames)))!; + prev.push({ + category: ts.DiagnosticCategory.Error, + file: sourceFile, + code: 9999, + length: 3, + messageText: customMessage, + start: 0 + }); + return prev; + }; + return proxy; + }, + onConfigurationChanged(config: any) { + customMessage = config.message; + } + }), + error: undefined + }; + default: return { module: undefined, diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 2f5b1d91d..167e2eff2 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -471,6 +471,8 @@ namespace ts.server { public readonly globalPlugins: ReadonlyArray; public readonly pluginProbeLocations: ReadonlyArray; public readonly allowLocalPluginLoads: boolean; + private currentPluginConfigOverrides: Map | undefined; + public readonly typesMapLocation: string | undefined; public readonly syntaxOnly?: boolean; @@ -1667,7 +1669,7 @@ namespace ts.server { project.enableLanguageService(); project.watchWildcards(createMapFromTemplate(parsedCommandLine.wildcardDirectories!)); // TODO: GH#18217 } - project.enablePluginsWithOptions(compilerOptions); + project.enablePluginsWithOptions(compilerOptions, this.currentPluginConfigOverrides); const filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles()); this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition!, parsedCommandLine.compileOnSave!); // TODO: GH#18217 } @@ -1857,7 +1859,7 @@ namespace ts.server { private createInferredProject(currentDirectory: string | undefined, isSingleInferredProject?: boolean, projectRootPath?: NormalizedPath): InferredProject { const compilerOptions = projectRootPath && this.compilerOptionsForInferredProjectsPerProjectRoot.get(projectRootPath) || this.compilerOptionsForInferredProjects; - const project = new InferredProject(this, this.documentRegistry, compilerOptions, projectRootPath, currentDirectory); + const project = new InferredProject(this, this.documentRegistry, compilerOptions, projectRootPath, currentDirectory, this.currentPluginConfigOverrides); if (isSingleInferredProject) { this.inferredProjects.unshift(project); } @@ -2806,6 +2808,16 @@ namespace ts.server { return false; } + + configurePlugin(args: protocol.ConfigurePluginRequestArguments) { + // For any projects that already have the plugin loaded, configure the plugin + this.forEachEnabledProject(project => project.onPluginConfigurationChanged(args.pluginName, args.configuration)); + + // Also save the current configuration to pass on to any projects that are yet to be loaded. + // If a plugin is configured twice, only the latest configuration will be remembered. + this.currentPluginConfigOverrides = this.currentPluginConfigOverrides || createMap(); + this.currentPluginConfigOverrides.set(args.pluginName, args.configuration); + } } /* @internal */ diff --git a/src/server/project.ts b/src/server/project.ts index e0297c640..1d22a99f8 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -72,6 +72,12 @@ namespace ts.server { export interface PluginModule { create(createInfo: PluginCreateInfo): LanguageService; getExternalFiles?(proj: Project): string[]; + onConfigurationChanged?(config: any): void; + } + + export interface PluginModuleWithName { + name: string; + module: PluginModule; } export type PluginModuleFactory = (mod: { typescript: typeof ts }) => PluginModule; @@ -92,7 +98,7 @@ namespace ts.server { private program: Program; private externalFiles: SortedReadonlyArray; private missingFilesMap: Map; - private plugins: PluginModule[] = []; + private plugins: PluginModuleWithName[] = []; /*@internal*/ /** @@ -549,9 +555,9 @@ namespace ts.server { getExternalFiles(): SortedReadonlyArray { return toSortedArray(flatMap(this.plugins, plugin => { - if (typeof plugin.getExternalFiles !== "function") return; + if (typeof plugin.module.getExternalFiles !== "function") return; try { - return plugin.getExternalFiles(this); + return plugin.module.getExternalFiles(this); } catch (e) { this.projectService.logger.info(`A plugin threw an exception in getExternalFiles: ${e}`); @@ -1105,7 +1111,7 @@ namespace ts.server { this.rootFilesMap.delete(info.path); } - protected enableGlobalPlugins(options: CompilerOptions) { + protected enableGlobalPlugins(options: CompilerOptions, pluginConfigOverrides: Map | undefined) { const host = this.projectService.host; if (!host.require) { @@ -1128,12 +1134,13 @@ namespace ts.server { // Provide global: true so plugins can detect why they can't find their config this.projectService.logger.info(`Loading global plugin ${globalPluginName}`); - this.enablePlugin({ name: globalPluginName, global: true } as PluginImport, searchPaths); + + this.enablePlugin({ name: globalPluginName, global: true } as PluginImport, searchPaths, pluginConfigOverrides); } } } - protected enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[]) { + protected enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[], pluginConfigOverrides: Map | undefined) { this.projectService.logger.info(`Enabling plugin ${pluginConfigEntry.name} from candidate paths: ${searchPaths.join(",")}`); const log = (message: string) => { @@ -1143,6 +1150,14 @@ namespace ts.server { const resolvedModule = firstDefined(searchPaths, searchPath => Project.resolveModule(pluginConfigEntry.name, searchPath, this.projectService.host, log)); if (resolvedModule) { + const configurationOverride = pluginConfigOverrides && pluginConfigOverrides.get(pluginConfigEntry.name); + if (configurationOverride) { + // Preserve the name property since it's immutable + const pluginName = pluginConfigEntry.name; + pluginConfigEntry = configurationOverride; + pluginConfigEntry.name = pluginName; + } + this.enableProxy(resolvedModule, pluginConfigEntry); } else { @@ -1150,11 +1165,6 @@ namespace ts.server { } } - /** Starts a new check for diagnostics. Call this if some file has updated that would cause diagnostics to be changed. */ - refreshDiagnostics() { - this.projectService.sendProjectsUpdatedInBackgroundEvent(); - } - private enableProxy(pluginModuleFactory: PluginModuleFactory, configEntry: PluginImport) { try { if (typeof pluginModuleFactory !== "function") { @@ -1180,12 +1190,26 @@ namespace ts.server { } this.projectService.logger.info(`Plugin validation succeded`); this.languageService = newLS; - this.plugins.push(pluginModule); + this.plugins.push({ name: configEntry.name, module: pluginModule }); } catch (e) { this.projectService.logger.info(`Plugin activation failed: ${e}`); } } + + /*@internal*/ + onPluginConfigurationChanged(pluginName: string, configuration: any) { + this.plugins.filter(plugin => plugin.name === pluginName).forEach(plugin => { + if (plugin.module.onConfigurationChanged) { + plugin.module.onConfigurationChanged(configuration); + } + }); + } + + /** Starts a new check for diagnostics. Call this if some file has updated that would cause diagnostics to be changed. */ + refreshDiagnostics() { + this.projectService.sendProjectsUpdatedInBackgroundEvent(); + } } /** @@ -1241,7 +1265,8 @@ namespace ts.server { documentRegistry: DocumentRegistry, compilerOptions: CompilerOptions, projectRootPath: NormalizedPath | undefined, - currentDirectory: string | undefined) { + currentDirectory: string | undefined, + pluginConfigOverrides: Map | undefined) { super(InferredProject.newName(), ProjectKind.Inferred, projectService, @@ -1257,7 +1282,7 @@ namespace ts.server { if (!projectRootPath && !projectService.useSingleInferredProject) { this.canonicalCurrentDirectory = projectService.toCanonicalFileName(this.currentDirectory); } - this.enableGlobalPlugins(this.getCompilerOptions()); + this.enableGlobalPlugins(this.getCompilerOptions(), pluginConfigOverrides); } addRoot(info: ScriptInfo) { @@ -1402,12 +1427,8 @@ namespace ts.server { return program && program.getResolvedProjectReferences(); } - enablePlugins() { - this.enablePluginsWithOptions(this.getCompilerOptions()); - } - /*@internal*/ - enablePluginsWithOptions(options: CompilerOptions) { + enablePluginsWithOptions(options: CompilerOptions, pluginConfigOverrides: Map | undefined) { const host = this.projectService.host; if (!host.require) { @@ -1428,11 +1449,11 @@ namespace ts.server { // Enable tsconfig-specified plugins if (options.plugins) { for (const pluginConfigEntry of options.plugins) { - this.enablePlugin(pluginConfigEntry, searchPaths); + this.enablePlugin(pluginConfigEntry, searchPaths, pluginConfigOverrides); } } - this.enableGlobalPlugins(options); + this.enableGlobalPlugins(options, pluginConfigOverrides); } /** diff --git a/src/server/protocol.ts b/src/server/protocol.ts index f0adab6f6..aad28416e 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -129,6 +129,7 @@ namespace ts.server.protocol { GetEditsForFileRename = "getEditsForFileRename", /* @internal */ GetEditsForFileRenameFull = "getEditsForFileRename-full", + ConfigurePlugin = "configurePlugin" // NOTE: If updating this, be sure to also update `allCommandNames` in `harness/unittests/session.ts`. } @@ -1370,6 +1371,16 @@ namespace ts.server.protocol { export interface ConfigureResponse extends Response { } + export interface ConfigurePluginRequestArguments { + pluginName: string; + configuration: any; + } + + export interface ConfigurePluginRequest extends Request { + command: CommandTypes.ConfigurePlugin; + arguments: ConfigurePluginRequestArguments; + } + /** * Information found in an "open" request. */ diff --git a/src/server/session.ts b/src/server/session.ts index bcbfc4773..16ad79a93 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1953,6 +1953,10 @@ namespace ts.server { this.updateErrorCheck(next, checkList, delay, /*requireOpen*/ false); } + private configurePlugin(args: protocol.ConfigurePluginRequestArguments) { + this.projectService.configurePlugin(args); + } + getCanonicalFileName(fileName: string) { const name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); return normalizePath(name); @@ -2274,6 +2278,10 @@ namespace ts.server { [CommandNames.GetEditsForFileRenameFull]: (request: protocol.GetEditsForFileRenameRequest) => { return this.requiredResponse(this.getEditsForFileRename(request.arguments, /*simplifiedResult*/ false)); }, + [CommandNames.ConfigurePlugin]: (request: protocol.ConfigurePluginRequest) => { + this.configurePlugin(request.arguments); + return this.notRequired(); + } }); public addProtocolHandler(command: string, handler: (request: protocol.Request) => HandlerResponse) { diff --git a/src/services/getEditsForFileRename.ts b/src/services/getEditsForFileRename.ts index a18fab476..6f7a26a0e 100644 --- a/src/services/getEditsForFileRename.ts +++ b/src/services/getEditsForFileRename.ts @@ -72,7 +72,7 @@ namespace ts { case "compilerOptions": forEachProperty(property.initializer, (property, propertyName) => { const option = getOptionFromName(propertyName); - if (option && (option.isFilePath || option.type === "list" && (option as CommandLineOptionOfListType).element.isFilePath)) { + if (option && (option.isFilePath || option.type === "list" && (option as CommandLineOptionOfListType).element.isFilePath)) { // tslint:disable-line no-unnecessary-type-assertion updatePaths(property); } else if (propertyName === "paths") { diff --git a/src/services/services.ts b/src/services/services.ts index fa540c137..542cc8698 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1367,11 +1367,7 @@ namespace ts { function getSyntacticDiagnostics(fileName: string): DiagnosticWithLocation[] { synchronizeHostData(); - let targetSourceFile: SourceFile; - if (fileName) { - targetSourceFile = getValidSourceFile(fileName); - } - return program.getSyntacticDiagnostics(targetSourceFile!, cancellationToken).slice(); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken).slice(); } /** @@ -1381,21 +1377,18 @@ namespace ts { function getSemanticDiagnostics(fileName: string): Diagnostic[] { synchronizeHostData(); - let targetSourceFile: SourceFile; - if (fileName) { - targetSourceFile = getValidSourceFile(fileName); - } + const targetSourceFile = getValidSourceFile(fileName); // Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file. // Therefore only get diagnostics for given file. - const semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile!, cancellationToken); + const semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); if (!getEmitDeclarations(program.getCompilerOptions())) { return semanticDiagnostics.slice(); } // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface - const declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile!, cancellationToken); + const declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); return [...semanticDiagnostics, ...declarationDiagnostics]; } @@ -1589,13 +1582,9 @@ namespace ts { function getEmitOutput(fileName: string, emitOnlyDtsFiles = false) { synchronizeHostData(); - let sourceFile: SourceFile; - if (fileName) { - sourceFile = getValidSourceFile(fileName); - } - + const sourceFile = getValidSourceFile(fileName); const customTransformers = host.getCustomTransformers && host.getCustomTransformers(); - return getFileEmitOutput(program, sourceFile!, emitOnlyDtsFiles, cancellationToken, customTransformers); + return getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers); } // Signature help diff --git a/src/tsc/tsc.ts b/src/tsc/tsc.ts index e9de13eba..ec2d029e6 100644 --- a/src/tsc/tsc.ts +++ b/src/tsc/tsc.ts @@ -215,24 +215,7 @@ namespace ts { configFileParsingDiagnostics }; const program = createProgram(programOptions); - - let exitStatus: number = ExitStatus.Success; - if (options.reorderFiles) { - let sortResult = ts.reorderSourceFiles(program); - if (sortResult.circularReferences.length > 0) { - let errorText: string = ""; - errorText += "error: Find circular dependencies when reordering file :" + ts.sys.newLine; - errorText += " at " + sortResult.circularReferences.join(ts.sys.newLine + " at ") + ts.sys.newLine + " at ..."; - sys.write(errorText + sys.newLine); - exitStatus = ExitStatus.DiagnosticsPresent_OutputsGenerated; - } - } - - const exitCode = emitFilesAndReportErrors(program, reportDiagnostic, s => sys.write(s + sys.newLine)); - if(exitCode != ExitStatus.Success){ - exitStatus = exitCode; - } - + const exitStatus = emitFilesAndReportErrors(program, reportDiagnostic, s => sys.write(s + sys.newLine)); reportStatistics(program); return sys.exit(exitStatus); }